From 428a37acb082502abecd782d5518e01809f6693c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 28 Mar 2018 11:13:07 +0430 Subject: [PATCH] improve prod chunk splitting --- lib/builder/webpack/client.js | 10 +++++++++- lib/common/nuxt.config.js | 1 + lib/common/options.js | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/builder/webpack/client.js b/lib/builder/webpack/client.js index 95caa63eef..ee8fddacf8 100644 --- a/lib/builder/webpack/client.js +++ b/lib/builder/webpack/client.js @@ -113,7 +113,15 @@ export default class WebpackClientConfig extends WebpackBaseConfig { new UglifyJsWebpackPlugin({ parallel: true, cache: this.options.build.cache, - sourceMap: false + sourceMap: false, + extractComments: { + filename: 'LICENSES' + }, + uglifyOptions: { + output: { + comments: /^\**!|@preserve|@license|@cc_on/ + } + } }) ] } diff --git a/lib/common/nuxt.config.js b/lib/common/nuxt.config.js index e2b5e12a86..0841309a01 100644 --- a/lib/common/nuxt.config.js +++ b/lib/common/nuxt.config.js @@ -58,6 +58,7 @@ export default { splitChunks: { chunks: 'all', automaticNameDelimiter: '.', + name: undefined, cacheGroups: {} } }, diff --git a/lib/common/options.js b/lib/common/options.js index 32ed18ee8a..90a3b1fa98 100644 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -177,6 +177,12 @@ Options.from = function (_options) { options.generate.fallback = '404.html' } + // Enable [name] when analyze or dev mode + if (options.build.optimization.splitChunks.name === undefined && + (options.dev || options.build.analyze)) { + options.build.optimization.splitChunks.name = true + } + // TODO: remove when mini-css-extract-plugin supports HMR if (options.dev) { options.build.extractCSS = false