Skip to content

Commit dbc9af6

Browse files
test: issue 1873 (#1876)
1 parent 5ec703d commit dbc9af6

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

spec/basic.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3798,4 +3798,32 @@ describe("HtmlWebpackPlugin", () => {
37983798
done,
37993799
);
38003800
});
3801+
3802+
it("allow you to use custom HTML tag attributes in templates", (done) => {
3803+
testHtmlPlugin(
3804+
{
3805+
mode: "production",
3806+
entry: path.join(__dirname, "fixtures/index.js"),
3807+
output: {
3808+
path: OUTPUT_DIR,
3809+
filename: "index_bundle.js",
3810+
},
3811+
plugins: [
3812+
new HtmlWebpackPlugin({
3813+
template: path.join(__dirname, "fixtures/template.ejs"),
3814+
baseHref: "/",
3815+
minify: false,
3816+
appMountIds: ["react-app", "portal-root"],
3817+
favicon: path.join(__dirname, "fixtures/favicon.ico"),
3818+
inject: false,
3819+
}),
3820+
],
3821+
},
3822+
[
3823+
/<script src="index_bundle.js" type="text\/javascript" nonce="NONCE"><\/script>/,
3824+
],
3825+
null,
3826+
done,
3827+
);
3828+
});
38013829
});

spec/fixtures/template.ejs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head></head>
4+
<body>
5+
<div id="react-app"></div>
6+
<% for (item of htmlWebpackPlugin.files.js) { %>
7+
<% if (typeof item === 'string' || item instanceof String) {
8+
item = { src: item, type: 'text/javascript' }
9+
} %>
10+
<script<% for (key in item) { %> <%= key %>="<%= item[key] %>"<% } %> nonce="NONCE"></script>
11+
<% } %>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)