Merge pull request #249 from sandeep45/master

build public path with correct hash value
This commit is contained in:
Jan Nicklas 2016-03-17 07:04:33 +01:00
commit 67ca550b99
2 changed files with 13 additions and 1 deletions

View File

@ -339,7 +339,7 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function (compilation, chu
// Use the configured public path or build a relative path
var publicPath = typeof compilation.options.output.publicPath !== 'undefined'
? compilation.options.output.publicPath
? compilation.mainTemplate.getPublicPath({hash: webpackStatsJson.hash})
: path.relative(path.dirname(self.options.filename), '.').split(path.sep).join('/');
if (publicPath.length && publicPath.substr(-1, 1) !== '/') {

View File

@ -355,6 +355,18 @@ describe('HtmlWebpackPlugin', function () {
}, [/<script src="index_bundle_[0-9a-f]+\.js"*/], null, done);
});
it('handles hashes in the directory which has the bundle file', function (done) {
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/index.js'),
output: {
path: path.join(__dirname, '../dist'),
publicPath: '/dist/[hash]/',
filename: 'index_bundle_[hash].js'
},
plugins: [new HtmlWebpackPlugin()]
}, [/<script src="\/dist\/[0-9a-f]+\/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'),