diff --git a/index.js b/index.js index 15ae156..425a619 100644 --- a/index.js +++ b/index.js @@ -89,7 +89,7 @@ HtmlWebpackPlugin.prototype.didChunkFilesChange = function(chunks) { var files = _.flatten(chunks.map(function(chunk) { return chunk.files; })); - if(_.difference(files, this.filesOfLastRun).length > 0) { + if(!this.filesOfLastRun || _.difference(files, this.filesOfLastRun).length > 0) { this.filesOfLastRun = files; return true; } @@ -248,9 +248,9 @@ HtmlWebpackPlugin.prototype.addFileToAssets = function(filename, compilation) { */ HtmlWebpackPlugin.prototype.filterChunks = function (webpackStatsJson, includedChunks, excludedChunks) { var chunks = webpackStatsJson.chunks.filter(function(chunk){ - var chunkName = chunk.names; + var chunkName = chunk.names[0]; // This chunk doesn't have a name. This script can't handled it. - if(chunkName === undefined) { + if (chunkName === undefined) { return false; } // Skip if the chunks should be filtered and the given chunk was not added explicity diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index d11e886..123cfae 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -24,6 +24,14 @@ function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expect } else { expect(compilationWarnings).toBe(''); } +<<<<<<< HEAD +======= + var outputFileExists = fs.existsSync(path.join(OUTPUT_DIR, outputFile)); + expect(outputFileExists).toBe(true); + if(!outputFileExists) { + return done(); + } +>>>>>>> Fix chunk filtering var htmlContent = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString(); for (var i = 0; i < expectedResults.length; i++) {