From 0d727cc23ee3441af99a404ae32f3dd0f1e981dd Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Mon, 15 Jun 2015 20:19:12 +0100 Subject: [PATCH] [async] make sure the async chunks aren't included in the html --- index.js | 5 +++++ spec/HtmlWebpackPluginSpec.js | 5 +++-- spec/fixtures/async.js | 1 + spec/fixtures/index.js | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/async.js diff --git a/index.js b/index.js index 8b23c222..22604ce0 100644 --- a/index.js +++ b/index.js @@ -206,6 +206,11 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp var chunk = chunks[i]; var chunkName = chunk.names[0]; + // This chunk doesn't have a name. This script can't handled it. + if(chunkName === undefined) { + continue; + } + // Skip if the chunks should be filtered and the given chunk was not added explicity if (Array.isArray(includedChunks) && includedChunks.indexOf(chunkName) === -1) { continue; diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index 105ce1f1..43db916b 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -23,8 +23,9 @@ function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expect expect(compilationWarnings).not.toBe(''); } else { expect(compilationWarnings).toBe(''); - } + } var htmlContent = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString(); + for (var i = 0; i < expectedResults.length; i++) { var expectedResult = expectedResults[i]; if (expectedResult instanceof RegExp) { @@ -50,7 +51,7 @@ describe('HtmlWebpackPlugin', function() { filename: 'index_bundle.js' }, plugins: [new HtmlWebpackPlugin()] - }, ['