Update webpack config to use parallel uglify plugin to speed up production build

This commit is contained in:
Wu Cheng-Han 2017-02-03 22:05:09 +08:00
parent 5ce5d4cd84
commit 15bf2b6da8
2 changed files with 11 additions and 7 deletions

View File

@ -163,6 +163,7 @@
"script-loader": "^0.7.0", "script-loader": "^0.7.0",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^1.14.0" "webpack": "^1.14.0",
"webpack-parallel-uglify-plugin": "^0.2.0"
} }
} }

View File

@ -3,6 +3,7 @@ var webpack = require('webpack');
var path = require('path'); var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin"); var ExtractTextPlugin = require("extract-text-webpack-plugin");
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
var ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
module.exports = [Object.assign({}, baseConfig, { module.exports = [Object.assign({}, baseConfig, {
plugins: baseConfig.plugins.concat([ plugins: baseConfig.plugins.concat([
@ -11,12 +12,14 @@ module.exports = [Object.assign({}, baseConfig, {
'NODE_ENV': JSON.stringify('production') 'NODE_ENV': JSON.stringify('production')
} }
}), }),
new webpack.optimize.UglifyJsPlugin({ new ParallelUglifyPlugin({
uglifyJS: {
compress: { compress: {
warnings: false warnings: false
}, },
mangle: false, mangle: false,
sourceMap: false sourceMap: false
}
}), }),
new ExtractTextPlugin("[name].[hash].css") new ExtractTextPlugin("[name].[hash].css")
]), ]),