diff --git a/CHANGELOG.md b/CHANGELOG.md index c7156ac..2e7a5e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Change History ============== +v2.13.0 +---- +* Add support for absolute output file names +* Add support for relative file names outside the output path + v2.12.0 ---- * Basic Webpack 2.x support #225 diff --git a/index.js b/index.js index e5d2384..c93f0db 100644 --- a/index.js +++ b/index.js @@ -346,8 +346,11 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function (compilation, chu // Use the configured public path or build a relative path var publicPath = typeof compilation.options.output.publicPath !== 'undefined' + // If a hard coded public path exists use it ? compilation.mainTemplate.getPublicPath({hash: webpackStatsJson.hash}) - : path.relative(path.dirname(self.options.filename), '.').split(path.sep).join('/'); + // If no public path was set get a relative url path + : path.relative(path.resolve(compilation.options.output.path, path.dirname(self.options.filename)), compilation.options.output.path) + .split(path.sep).join('/'); if (publicPath.length && publicPath.substr(-1, 1) !== '/') { publicPath += '/'; diff --git a/package.json b/package.json index 67a7067..c145c2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-plugin", - "version": "2.12.0", + "version": "2.13.0", "description": "Simplifies creation of HTML files to serve your webpack bundles", "main": "index.js", "files": [ @@ -11,6 +11,7 @@ "scripts": { "prepublish": "npm run test", "pretest": "semistandard", + "recompile": "node examples/rebuild.js", "test": "jasmine" }, "repository": { diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index d848891..a653f33 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -578,10 +578,36 @@ describe('HtmlWebpackPlugin', function () { path: OUTPUT_DIR, filename: 'index_bundle.js' }, + plugins: [new HtmlWebpackPlugin({ + filename: path.resolve(OUTPUT_DIR, 'subfolder', 'test.html') + })] + }, ['