From f5b9140cc3232cb695453d8e5f3140a5af59acc8 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:26:21 +0300 Subject: [PATCH] fix: allow bundle empty html (#1865) --- 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..b26856679 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"), + }), + ], + }, + ['