Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions spec/basic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3798,4 +3798,32 @@ describe("HtmlWebpackPlugin", () => {
done,
);
});

it("allow you to use custom HTML tag attributes in templates", (done) => {
testHtmlPlugin(
{
mode: "production",
entry: path.join(__dirname, "fixtures/index.js"),
output: {
path: OUTPUT_DIR,
filename: "index_bundle.js",
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "fixtures/template.ejs"),
baseHref: "/",
minify: false,
appMountIds: ["react-app", "portal-root"],
favicon: path.join(__dirname, "fixtures/favicon.ico"),
inject: false,
}),
],
},
[
/<script src="index_bundle.js" type="text\/javascript" nonce="NONCE"><\/script>/,
],
null,
done,
);
});
});
13 changes: 13 additions & 0 deletions spec/fixtures/template.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="react-app"></div>
<% for (item of htmlWebpackPlugin.files.js) { %>
<% if (typeof item === 'string' || item instanceof String) {
item = { src: item, type: 'text/javascript' }
} %>
<script<% for (key in item) { %> <%= key %>="<%= item[key] %>"<% } %> nonce="NONCE"></script>
<% } %>
</body>
</html>
Loading