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()] - }, ['