Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/favicon/dist/webpack-1/favicon.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>HtmlWebpackPlugin example</title>
<link rel="shortcut icon" href="favicon.ico"><link href="styles.css" rel="stylesheet"></head>
<link rel="shortcut icon" href="favicon.ico.gz"><link href="styles.css.gz" rel="stylesheet"></head>
<body>
<script type="text/javascript" src="bundle.js"></script></body>
<script type="text/javascript" src="bundle.js.gz"></script></body>
</html>
4 changes: 2 additions & 2 deletions examples/favicon/dist/webpack-2/favicon.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>HtmlWebpackPlugin example</title>
<link rel="shortcut icon" href="favicon.ico"><link href="styles.css" rel="stylesheet"></head>
<link rel="shortcut icon" href="favicon.ico.gz"><link href="styles.css.gz" rel="stylesheet"></head>
<body>
<script type="text/javascript" src="bundle.js"></script></body>
<script type="text/javascript" src="bundle.js.gz"></script></body>
</html>
3 changes: 2 additions & 1 deletion examples/favicon/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
new HtmlWebpackPlugin({
title: 'HtmlWebpackPlugin example',
favicon: 'favicon.ico',
filename: 'favicon.html'
filename: 'favicon.html',
useGzip: true
}),
new ExtractTextPlugin('styles.css')
]
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function HtmlWebpackPlugin (options) {
this.options = _.extend({
template: path.join(__dirname, 'default_index.ejs'),
filename: 'index.html',
useGzip: false,
hash: false,
inject: true,
compile: true,
Expand Down Expand Up @@ -99,7 +100,7 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) {
if (publicPath && publicPath.substr(-1) !== '/') {
publicPath += '/';
}
assets.favicon = publicPath + faviconBasename;
assets.favicon = publicPath + faviconBasename + (self.options.useGzip ? '.gz' : '');
});
}
})
Expand Down Expand Up @@ -466,14 +467,15 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function (compilation, chu
* Injects the assets into the given html string
*/
HtmlWebpackPlugin.prototype.generateAssetTags = function (assets) {
var gzipSuffix = this.options.useGzip ? '.gz' : '';
// Turn script files into script tags
var scripts = assets.js.map(function (scriptPath) {
return {
tagName: 'script',
closeTag: true,
attributes: {
type: 'text/javascript',
src: scriptPath
src: scriptPath + gzipSuffix
}
};
});
Expand All @@ -485,7 +487,7 @@ HtmlWebpackPlugin.prototype.generateAssetTags = function (assets) {
tagName: 'link',
selfClosingTag: selfClosingTag,
attributes: {
href: stylePath,
href: stylePath + gzipSuffix,
rel: 'stylesheet'
}
};
Expand Down