perf: speed up uglify-js by using parallel and cache options

This commit is contained in:
Pooya Parsa 2018-03-23 01:00:51 +04:30
parent 686a54134d
commit 7e308f9340
3 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import webpack from 'webpack'
import HTMLPlugin from 'html-webpack-plugin'
import BundleAnalyzer from 'webpack-bundle-analyzer'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import UglifyJsWebpackPlugin from 'uglifyjs-webpack-plugin'
import VueSSRClientPlugin from './plugins/vue/client'
import BaseConfig from './base'
@ -105,8 +106,20 @@ export default class WebpackClientConfig extends BaseConfig {
}
}
// Make uglifyjs faster
if (!this.options.dev && !config.optimization.minimizer) {
// https://github.com/webpack-contrib/uglifyjs-webpack-plugin
config.optimization.minimizer = [
new UglifyJsWebpackPlugin({
parallel: true,
cache: true,
sourceMap: false
})
]
}
// Add HMR support
if (this.options.dev) {
// Add HMR support
config.entry = [
// https://github.com/glenjamin/webpack-hot-middleware#config
`webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=${

View File

@ -102,6 +102,7 @@
"source-map": "^0.7.2",
"style-resources-loader": "^1.1.0",
"time-fix-plugin": "^2.0.0",
"uglifyjs-webpack-plugin": "^1.2.4",
"upath": "^1.0.2",
"url-loader": "^1.0.1",
"vue": "^2.5.16",

View File

@ -7115,7 +7115,7 @@ uglify-to-browserify@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
uglifyjs-webpack-plugin@^1.1.1:
uglifyjs-webpack-plugin@^1.1.1, uglifyjs-webpack-plugin@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.4.tgz#5eec941b2e9b8538be0a20fc6eda25b14c7c1043"
dependencies: