Skip to content

Commit

Permalink
Fix chunk filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon authored and Jan Nicklas committed Jun 3, 2015
1 parent 56cd691 commit 308bff3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ 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];
// Skip if the chunks should be filtered and the given chunk was not added explicity
if (Array.isArray(includedChunks) && includedChunks.indexOf(chunkName) === -1) {
return false;
Expand Down
5 changes: 5 additions & 0 deletions spec/HtmlWebpackPluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expect
expect(compilationWarnings).not.toBe('');
} else {
expect(compilationWarnings).toBe('');
}
var outputFileExists = fs.existsSync(path.join(OUTPUT_DIR, outputFile));
expect(outputFileExists).toBe(true);
if(!outputFileExists) {
return done();
}
var htmlContent = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString();
for (var i = 0; i < expectedResults.length; i++) {
Expand Down

0 comments on commit 308bff3

Please sign in to comment.