Skip to content

Instantly share code, notes, and snippets.

@pablohpsilva
Created October 28, 2017 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablohpsilva/5b736d24327b2631e3b4d88c442d2958 to your computer and use it in GitHub Desktop.
Save pablohpsilva/5b736d24327b2631e3b4d88c442d2958 to your computer and use it in GitHub Desktop.
measure5-webpack.prod.conf.js
var
// ...
SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'),
loadMinified = require('./load-minified'),
// ...
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
// ...
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../dist/index.html'),
template: 'src/index.html',
inject: true,
minify: {
html5: true,
useShortDoctype: true,
decodeEntities: true,
removeTagWhitespace: true,
removeStyleLinkTypeAttributes: true,
removeScriptTypeAttributes: true,
minifyCSS: true,
minifyJS: true,
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: false,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
preserveLineBreaks: false,
sortAttributes: true,
sortClassName: true,
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency',
serviceWorkerLoader: `<script>${loadMinified(path.join(__dirname,
'./service-worker-prod.js'))}</script>`
}),
// ...
new SWPrecacheWebpackPlugin({
cacheId: 'toodo-app-v1',
filename: 'service-worker.js',
staticFileGlobs: ['dist/**/*.{js,json,html,css,json,png,svg,woff}'],
minify: true,
stripPrefix: 'dist/'
}),
// ...
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment