From c984c2b9dae73d0f946d733de3b9b3ec0dec2635 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Thu, 17 Oct 2024 20:13:37 +0300 Subject: [PATCH 1/2] fix: allow bundle empty html --- index.js | 2 +- spec/basic.spec.js | 23 +++++++++++++++++++++++ spec/fixtures/empty.html | 0 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/empty.html diff --git a/index.js b/index.js index f29b762d3..7ce484029 100644 --- a/index.js +++ b/index.js @@ -705,7 +705,7 @@ class HtmlWebpackPlugin { if ( typeof newSource === "object" && newSource.__esModule && - newSource.default + newSource.default !== undefined ) { newSource = newSource.default; } diff --git a/spec/basic.spec.js b/spec/basic.spec.js index 14cbef6b2..77c34f96d 100644 --- a/spec/basic.spec.js +++ b/spec/basic.spec.js @@ -3775,4 +3775,27 @@ describe("HtmlWebpackPlugin", () => { }, ); }); + + it("allows you to use empty HTML template file", (done) => { + testHtmlPlugin( + { + mode: "production", + entry: { + app: path.join(__dirname, "fixtures/index.js"), + }, + output: { + path: OUTPUT_DIR, + filename: "[name]_bundle.js", + }, + plugins: [ + new HtmlWebpackPlugin({ + template: path.join(__dirname, "fixtures/empty.html") + }), + ], + }, + ['