Skip to content

Commit f5b9140

Browse files
fix: allow bundle empty html (#1865)
1 parent 832e0f9 commit f5b9140

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ class HtmlWebpackPlugin {
705705
if (
706706
typeof newSource === "object" &&
707707
newSource.__esModule &&
708-
newSource.default
708+
newSource.default !== undefined
709709
) {
710710
newSource = newSource.default;
711711
}

spec/basic.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,4 +3775,27 @@ describe("HtmlWebpackPlugin", () => {
37753775
},
37763776
);
37773777
});
3778+
3779+
it("allows you to use empty HTML template file", (done) => {
3780+
testHtmlPlugin(
3781+
{
3782+
mode: "production",
3783+
entry: {
3784+
app: path.join(__dirname, "fixtures/index.js"),
3785+
},
3786+
output: {
3787+
path: OUTPUT_DIR,
3788+
filename: "[name]_bundle.js",
3789+
},
3790+
plugins: [
3791+
new HtmlWebpackPlugin({
3792+
template: path.join(__dirname, "fixtures/empty.html"),
3793+
}),
3794+
],
3795+
},
3796+
['<script defer="defer" src="app_bundle.js'],
3797+
null,
3798+
done,
3799+
);
3800+
});
37783801
});

spec/fixtures/empty.html

Whitespace-only changes.

0 commit comments

Comments
 (0)