diff --git a/lib/builder/webpack/client.mjs b/lib/builder/webpack/client.mjs index adf8b463cd..a88b3a866d 100644 --- a/lib/builder/webpack/client.mjs +++ b/lib/builder/webpack/client.mjs @@ -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=${ diff --git a/package.json b/package.json index 37b67cb1e4..7ee8f782de 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index a176a89d68..c3097abb67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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: