diff --git a/index.js b/index.js index f014fc8..0964390 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ 'use strict'; var fs = require('fs'); var path = require('path'); + var urlModule = require('url'); var _ = require('lodash'); var tmpl = require('blueimp-tmpl').tmpl; var Promise = require('bluebird'); @@ -101,6 +102,8 @@ HtmlWebpackPlugin.prototype.getTemplateContent = function(compilation, templateP if (!templateFile) { // Use a special index file to prevent double script / style injection if the `inject` option is truthy templateFile = path.join(__dirname, self.options.inject ? 'default_inject_index.html' : 'default_index.html'); + } else { + templateFile = path.normalize(templateFile); } compilation.fileDependencies.push(templateFile); return fs.readFileAsync(templateFile, 'utf8') @@ -176,7 +179,7 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp path.relative(path.dirname(self.options.filename), '.'); if (publicPath.length && publicPath.substr(-1, 1) !== '/') { - publicPath += '/'; + publicPath = path.join(urlModule.resolve(publicPath + '/', '.'), '/'); } var assets = { diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index a8bde34..4a0ccbe 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -114,6 +114,23 @@ describe('HtmlWebpackPlugin', function() { }, ['