Merge pull request #86 from okhomenko/master

On Windows relative path doesn't work properly
This commit is contained in:
Jan Nicklas 2015-09-15 08:33:10 +02:00
commit 273371859b
2 changed files with 21 additions and 1 deletions

View File

@ -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 = {

View File

@ -114,6 +114,23 @@ describe('HtmlWebpackPlugin', function() {
}, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], null, done);
});
it('allows to specify windows/*nix paths to template', function (done) {
testHtmlPlugin({
entry: {
util: path.join(__dirname, 'fixtures/util.js'),
app: path.join(__dirname, 'fixtures/index.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name]_bundle.js'
},
plugins: [new HtmlWebpackPlugin({
inject: true,
template: path.join(__dirname, 'fixtures') + '/plain.html'
})]
}, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], null, done);
});
it('allows you to inject the assets into the body of the given template', function (done) {
testHtmlPlugin({
entry: {