diff --git a/README.md b/README.md
index 8efc6d6..64f438a 100644
--- a/README.md
+++ b/README.md
@@ -195,11 +195,6 @@ template is rendered. This variable has the following attributes:
If you've set a publicPath in your webpack config this will be reflected
correctly in this assets hash.
- - `htmlWebpackPlugin.querystring`: a unique compilation query string
- (eg: `?6682424b6ad9eb93151b`) that can be appended to the URL of included
- scripts and css for cache busting. Only set if `hash: true` is set in
- the plugin options.
-
- `htmlWebpackPlugin.options`: the options hash that was passed to
the plugin. In addition to the options actually used by this plugin,
you can use this hash to pass arbitrary data through to your template.
diff --git a/default_index.html b/default_index.html
index 7609a39..2dd1749 100644
--- a/default_index.html
+++ b/default_index.html
@@ -1,15 +1,15 @@
-
+
{%=o.htmlWebpackPlugin.options.title || 'Webpack App'%}
{% for (var css in o.htmlWebpackPlugin.files.css) { %}
-
+
{% } %}
{% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %}
-
+
{% } %}
diff --git a/index.js b/index.js
index feb9d2e..6ec4754 100644
--- a/index.js
+++ b/index.js
@@ -16,11 +16,8 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) {
templateParams.webpack = webpackStatsJson;
templateParams.htmlWebpackPlugin = {};
templateParams.htmlWebpackPlugin.assets = self.htmlWebpackPluginLegacyAssets(compilation, webpackStatsJson);
- templateParams.htmlWebpackPlugin.files = self.htmlWebpackPluginAssets(compilation, webpackStatsJson);
+ templateParams.htmlWebpackPlugin.files = self.htmlWebpackPluginAssets(compilation, webpackStatsJson, self.options.hash);
templateParams.htmlWebpackPlugin.options = self.options;
-
- // If the hash option is true append the webpack hash to all assets
- templateParams.htmlWebpackPlugin.querystring = self.options.hash ? '?' + webpackStatsJson.hash : '';
templateParams.webpackConfig = compilation.options;
var outputFilename = self.options.filename || 'index.html';
@@ -69,7 +66,10 @@ HtmlWebpackPlugin.prototype.emitHtml = function(compilation, htmlTemplateContent
};
-HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webpackStatsJson) {
+HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webpackStatsJson, appendHash) {
+ var publicPath = compilation.options.output.publicPath || '';
+ var queryString = appendHash ? '?' + webpackStatsJson.hash : '';
+
var assets = {
// Will contain all js & css files by chunk
chunks: {},
@@ -80,9 +80,10 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp
// Will contain the html5 appcache manifest files if it exists
manifest: Object.keys(compilation.assets).filter(function(assetFile){
return path.extname(assetFile) === '.appcache';
+ }).map(function(assetFile) {
+ return assetFile + queryString;
})[0]
};
- var publicPath = compilation.options.output.publicPath || '';
var chunks = webpackStatsJson.chunks.sort(function orderEntryLast(a, b) {
if (a.entry !== b.entry) {
@@ -99,7 +100,7 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp
// Prepend the public path to all chunk files
var chunkFiles = [].concat(chunk.files).map(function(chunkFile) {
- return publicPath + chunkFile;
+ return publicPath + chunkFile + queryString;
});
// Webpack outputs an array for each chunk when using sourcemaps