From 495ea523c291a8d672edb9f0b4294a2cd69291e7 Mon Sep 17 00:00:00 2001 From: hal-wang Date: Mon, 25 Jan 2021 17:20:45 +0800 Subject: [PATCH] add cacheGroups --- web/vue.config.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/web/vue.config.js b/web/vue.config.js index a57af2d3..f23223bb 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -33,6 +33,41 @@ module.exports = { } } }, + configureWebpack: config => { + config.optimization = { + splitChunks: { + cacheGroups: { + vendor: { + chunks: 'all', + test: /node_modules/, + name: 'vendor', + minChunks: 1, + maxInitialRequests: 5, + minSize: 0, + priority: 100 + }, + common: { + chunks: 'all', + test: /[\\/]src[\\/]js[\\/]/, + name: 'common', + minChunks: 2, + maxInitialRequests: 5, + minSize: 0, + priority: 60 + }, + styles: { + name: 'styles', + test: /\.(sa|sc|c)ss$/, + chunks: 'all', + enforce: true + }, + runtimeChunk: { + name: 'manifest' + } + } + } + } + }, chainWebpack(config) { config.plugins.delete('preload') config.plugins.delete('prefetch')