v2.9.0 Fix favicon path (#185 #208 #215)

This commit is contained in:
Jan Nicklas 2016-02-17 13:17:23 +01:00 committed by Jan Nicklas
parent b65c39c2f1
commit 713643f84f
3 changed files with 22 additions and 6 deletions

View File

@ -75,11 +75,11 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
if (self.options.favicon) {
return self.addFileToAssets(self.options.favicon, compilation)
.then(function (faviconBasename) {
if (compilation.options.output.publicPath) {
assets.favicon = compilation.options.output.publicPath + faviconBasename;
} else {
assets.favicon = faviconBasename;
var publicPath = compilation.options.output.publicPath || '';
if (publicPath && publicPath.substr(-1) !== '/') {
publicPath += '/';
}
assets.favicon = publicPath + faviconBasename;
});
}
})

View File

@ -1,6 +1,6 @@
{
"name": "html-webpack-plugin",
"version": "2.8.2",
"version": "2.9.0",
"description": "Simplifies creation of HTML files to serve your webpack bundles",
"main": "index.js",
"files": [

View File

@ -770,7 +770,7 @@ describe('HtmlWebpackPlugin', function () {
}, [/<link rel="shortcut icon" href="[^"]+\.ico">/], null, done);
});
it('adds a favicon with publicPath set', function (done) {
it('adds a favicon with publicPath set to /some/', function (done) {
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/index.js'),
output: {
@ -786,6 +786,22 @@ describe('HtmlWebpackPlugin', function () {
}, [/<link rel="shortcut icon" href="\/some\/+[^"]+\.ico">/], null, done);
});
it('adds a favicon with publicPath set to /some', function (done) {
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/index.js'),
output: {
path: OUTPUT_DIR,
publicPath: '/some',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
favicon: path.join(__dirname, 'fixtures/favicon.ico')
})
]
}, [/<link rel="shortcut icon" href="\/some\/+[^"]+\.ico">/], null, done);
});
it('adds a favicon with inject enabled', function (done) {
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/index.js'),