Skip to content

Commit

Permalink
use childCompilerHash to replace [hash] in filename
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiss-stripe committed Mar 31, 2016
1 parent d499aa9 commit f56103a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
// If the compilation change didnt change the cache is valid
isCompilationCached = compilationResult.hash && self.childCompilerHash === compilationResult.hash;
self.childCompilerHash = compilationResult.hash;
self.options.filename = self.options.filename.replace(/\[hash\]/g, compilationResult.hash);
callback();
return compilationResult.content;
});
Expand Down Expand Up @@ -150,20 +149,22 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
return self.options.showErrors ? prettyError(err, compiler.context).toHtml() : 'ERROR';
})
.then(function (html) {
var outputFilename = self.options.filename.replace(/\[hash\]/g, self.childCompilerHash)
// Replace the compilation result with the evaluated html code
compilation.assets[self.options.filename] = {
compilation.assets[outputFilename] = {
source: function () {
return html;
},
size: function () {
return html.length;
}
};
return outputFilename;
})
.then(function () {
.then(function (outputFilename) {
// Let other plugins know that we are done:
return applyPluginsAsyncWaterfall('html-webpack-plugin-after-emit', {
html: compilation.assets[self.options.filename],
html: compilation.assets[outputFilename],
plugin: self
});
})
Expand Down

0 comments on commit f56103a

Please sign in to comment.