Merge pull request #281 from dtinth/patch-1

Don’t emit the html for hot-update compilation.
This commit is contained in:
Jan Nicklas 2016-04-30 19:53:49 +02:00
commit 10058066d7
1 changed files with 12 additions and 0 deletions

View File

@ -70,6 +70,12 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
chunks = self.sortChunks(chunks, self.options.chunksSortMode);
// Get assets
var assets = self.htmlWebpackPluginAssets(compilation, chunks);
// If this is a hot update compilation, move on!
// This solves a problem where an `index.html` file is generated for hot-update js files
// It only happens in Webpack 2, where hot updates are emitted separately before the full bundle
if (self.isHotUpdateCompilation(assets)) {
return callback();
}
// If the template and the assets did not change we don't have to emit the html
var assetJson = JSON.stringify(self.getAssetFiles(assets));
@ -352,6 +358,12 @@ HtmlWebpackPlugin.prototype.filterChunks = function (webpackStatsJson, includedC
});
};
HtmlWebpackPlugin.prototype.isHotUpdateCompilation = function (assets) {
return assets.js.every(function (name) {
return /\.hot-update\.js$/.test(name);
});
};
HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function (compilation, chunks) {
var self = this;
var webpackStatsJson = compilation.getStats().toJson();