From d0105fd7a7e9cadd62166f94d34a5804c633a78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Wed, 6 Jul 2016 13:30:54 +0200 Subject: [PATCH] Don't treat templateContent set to an empty string as not specified Fix #355 --- index.js | 2 +- spec/BasicSpec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7775c24..f59d91b 100644 --- a/index.js +++ b/index.js @@ -107,7 +107,7 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) { }) .then(function (compiledTemplate) { // Allow to use a custom function / string instead - if (self.options.templateContent) { + if (self.options.templateContent !== undefined) { return self.options.templateContent; } // Once everything is compiled evaluate the html factory diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index 3ae22a3..05ce988 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -1239,4 +1239,18 @@ describe('HtmlWebpackPlugin', function () { ] }, ['templateParams.compilation exists: true'], null, done); }); + + it('should not treat templateContent set to an empty string as missing', function (done) { + testHtmlPlugin({ + entry: {app: path.join(__dirname, 'fixtures/index.js')}, + output: { + path: OUTPUT_DIR, + filename: 'app_bundle.js' + }, + plugins: [new HtmlWebpackPlugin({ + templateContent: '' + })] + }, + [/^