From 41a255a2f1a0be054b03ceb9231f538ffbf350af Mon Sep 17 00:00:00 2001 From: Thomas Guillory Date: Fri, 2 Oct 2015 16:13:51 +0200 Subject: [PATCH] FIX missing [hash] interpolation in publicPath Webpack gives the possibility to use the build [hash] in output.publicPath option: https://webpack.github.io/docs/long-term-caching.html However HtmlWebpackPlugin is reading directly the raw option, preventing the user to use this option when using it. --- index.js | 2 +- spec/HtmlWebpackPluginSpec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 0964390..e10a79e 100644 --- a/index.js +++ b/index.js @@ -175,7 +175,7 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp // 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), '.'); if (publicPath.length && publicPath.substr(-1, 1) !== '/') { diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index 4a0ccbe..8a2f9ba 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -304,6 +304,18 @@ describe('HtmlWebpackPlugin', function() { }, [/