Fix typo and manifest hash

This commit is contained in:
Jan Nicklas 2015-04-21 17:48:14 +02:00
parent 4060a42bfb
commit f8eab624f4
2 changed files with 17 additions and 2 deletions

View File

@ -211,7 +211,7 @@ template is rendered. This variable has the following attributes:
Filtering chunks
----------------
To include only certain chunks you can limit the chunks beeing used:
To include only certain chunks you can limit the chunks being used:
```javascript
plugins: [

View File

@ -72,6 +72,7 @@ HtmlWebpackPlugin.prototype.emitHtml = function(compilation, htmlTemplateContent
HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webpackStatsJson, includedChunks, excludedChunks) {
var self = this;
var publicPath = compilation.options.output.publicPath || '';
var assets = {
@ -87,6 +88,11 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp
})[0]
};
// Append a hash for cache busting
if (this.options.hash) {
assets.manifest = self.appendHash(assets.manifest, webpackStatsJson.hash);
}
var chunks = webpackStatsJson.chunks.sort(function orderEntryLast(a, b) {
if (a.entry !== b.entry) {
return b.entry ? 1 : -1;
@ -118,7 +124,7 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp
// Append a hash for cache busting
if (this.options.hash) {
chunkFiles = chunkFiles.map(function(chunkFile) {
return chunkFile + (chunkFile.indexOf('?') === -1 ? '?' : '&') + webpackStatsJson.hash;
return self.appendHash(chunkFile, webpackStatsJson.hash);
});
}
@ -200,6 +206,15 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginLegacyAssets = function(compilation
return legacyAssets;
};
/**
* Appends a cache busting hash
*/
HtmlWebpackPlugin.prototype.appendHash = function (url, hash) {
if (!url) {
return url;
}
return url + (url.indexOf('?') === -1 ? '?' : '&') + hash;
};
module.exports = HtmlWebpackPlugin;