Skip to content

Instantly share code, notes, and snippets.

@pablohpsilva
Created October 28, 2017 16:56
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/d5abcdf0923226238ef8f1125870dac5 to your computer and use it in GitHub Desktop.
Save pablohpsilva/d5abcdf0923226238ef8f1125870dac5 to your computer and use it in GitHub Desktop.
measure2-webpack.prod.config.js
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: config.build.productionSourceMap,
minimize: true,
compress: {
warnings: false, // warn about potentially dangerous optimizations/code
sequences: true, // join consecutive statemets with the “comma operator”
properties: true, // optimize property access: a["foo"] → a.foo
dead_code: true, // discard unreachable code
drop_debugger: true, // discard “debugger” statements
unsafe: true, // some unsafe optimizations (see below)
conditionals: true, // optimize if-s and conditional expressions
comparisons: true, // optimize comparisons
evaluate: true, // evaluate constant expressions
booleans: true, // optimize boolean expressions
loops: true, // optimize loops
unused: true, // drop unused variables/functions
hoist_funs: true, // hoist function declarations
hoist_vars: true, // hoist variable declarations
if_return: true, // optimize if-s followed by return/continue
join_vars: true, // join var declarations
cascade: true, // try to cascade `right` into `left` in sequences
side_effects: true, // drop side-effect-free statements
}
}),
// ...
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'
}),
// ...
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment