From e4e9555209500ca493b58556ec58a9c6ea102f97 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 23 Mar 2016 03:08:46 -0400 Subject: [PATCH] support absolute filenames --- index.js | 7 +++++++ spec/BasicSpec.js | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/index.js b/index.js index ab7a5f0..e5d2384 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,13 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) { this.options.template = this.getFullTemplatePath(this.options.template, compiler.context); + // convert absolute filename into relative so that webpack can + // generate it at correct location + var filename = this.options.filename; + if (path.resolve(filename) === path.normalize(filename)) { + this.options.filename = path.relative(compiler.options.output.path, filename); + } + compiler.plugin('make', function (compilation, callback) { // Compile the template (queued) compilationPromise = childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation) diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index af57640..d848891 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -571,6 +571,19 @@ describe('HtmlWebpackPlugin', function () { }, ['