Don't append a hash by default
This commit is contained in:
parent
1427d4e3d7
commit
442f016683
|
|
@ -1,15 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html{% if(o.htmlWebpackPlugin.files.manifest) { %} manifest="{%= o.htmlWebpackPlugin.files.manifest + '?' + o.hash %}"{% } %}>
|
||||
<html{% if(o.htmlWebpackPlugin.files.manifest) { %} manifest="{%= o.htmlWebpackPlugin.files.manifest + o.htmlWebpackPlugin.querystring %}"{% } %}>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{%=o.htmlWebpackPlugin.options.title || 'Webpack App'%}</title>
|
||||
{% for (var css in o.htmlWebpackPlugin.files.css) { %}
|
||||
<link href="{%=o.htmlWebpackPlugin.files.css[css] + '?' + o.hash %}" rel="stylesheet">
|
||||
<link href="{%=o.htmlWebpackPlugin.files.css[css] + o.htmlWebpackPlugin.querystring %}" rel="stylesheet">
|
||||
{% } %}
|
||||
</head>
|
||||
<body>
|
||||
{% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %}
|
||||
<script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry + '?' + o.hash %}"></script>
|
||||
<script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry + o.htmlWebpackPlugin.querystring %}"></script>
|
||||
{% } %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
3
index.js
3
index.js
|
|
@ -13,11 +13,12 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) {
|
|||
var webpackStatsJson = compilation.getStats().toJson();
|
||||
var templateParams = {};
|
||||
templateParams.webpack = webpackStatsJson;
|
||||
templateParams.hash = webpackStatsJson.hash;
|
||||
templateParams.htmlWebpackPlugin = {};
|
||||
templateParams.htmlWebpackPlugin.assets = self.htmlWebpackPluginLegacyAssets(compilation, webpackStatsJson);
|
||||
templateParams.htmlWebpackPlugin.files = self.htmlWebpackPluginAssets(compilation, webpackStatsJson);
|
||||
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 : '';
|
||||
|
||||
var outputFilename = self.options.filename || 'index.html';
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, ['<script src="index_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="index_bundle.js"'], null, done);
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: '[name]_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, ['<script src="util_bundle.js?%hash%"', '<script src="app_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], null, done);
|
||||
});
|
||||
|
||||
it('allows you to specify your own HTML template file', function(done) {
|
||||
|
|
@ -139,7 +139,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, ['<script src="index_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="index_bundle.js"'], null, done);
|
||||
});
|
||||
|
||||
it('handles hashes in bundle filenames', function(done) {
|
||||
|
|
@ -150,7 +150,18 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: 'index_bundle_[hash].js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, [/<script src="index_bundle_[0-9a-f]+\.js\?/], null, done);
|
||||
}, [/<script src="index_bundle_[0-9a-f]+\.js/], null, done);
|
||||
});
|
||||
|
||||
it('allows to append hashes to the assets', function(done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: OUTPUT_DIR,
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({hash: true})]
|
||||
}, ['<script src="index_bundle.js?%hash%"'], null, done);
|
||||
});
|
||||
|
||||
it('prepends the webpack public path to script src', function(done) {
|
||||
|
|
@ -162,7 +173,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
publicPath: 'http://cdn.example.com/assets/'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, ['<script src="http://cdn.example.com/assets/index_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="http://cdn.example.com/assets/index_bundle.js"'], null, done);
|
||||
});
|
||||
|
||||
it('handles subdirectories in the webpack output bundles', function(done) {
|
||||
|
|
@ -173,7 +184,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: 'assets/index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, ['<script src="assets/index_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="assets/index_bundle.js"'], null, done);
|
||||
});
|
||||
|
||||
it('handles subdirectories in the webpack output bundles along with a public path', function(done) {
|
||||
|
|
@ -185,7 +196,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
publicPath: 'http://cdn.example.com/'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin()]
|
||||
}, ['<script src="http://cdn.example.com/assets/index_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="http://cdn.example.com/assets/index_bundle.js"'], null, done);
|
||||
});
|
||||
|
||||
it('allows you to configure the title of the generated HTML page', function(done) {
|
||||
|
|
@ -207,7 +218,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({filename: 'test.html'})]
|
||||
}, ['<script src="index_bundle.js?%hash%"'], 'test.html', done);
|
||||
}, ['<script src="index_bundle.js"'], 'test.html', done);
|
||||
});
|
||||
|
||||
it('allows you to configure the output filename with a path', function(done) {
|
||||
|
|
@ -218,7 +229,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({filename: 'assets/test.html'})]
|
||||
}, ['<script src="index_bundle.js?%hash%"'], 'assets/test.html', done);
|
||||
}, ['<script src="index_bundle.js"'], 'assets/test.html', done);
|
||||
});
|
||||
|
||||
it('allows you write multiple HTML files', function(done) {
|
||||
|
|
@ -237,7 +248,7 @@ describe('HtmlWebpackPlugin', function() {
|
|||
template: path.join(__dirname, 'fixtures/test.html')
|
||||
})
|
||||
]
|
||||
}, ['<script src="index_bundle.js?%hash%"'], null, done);
|
||||
}, ['<script src="index_bundle.js"'], null, done);
|
||||
|
||||
expect(fs.existsSync(path.join(__dirname, 'fixtures/test.html'))).toBe(true);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue