在vue.config.js 中添加
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.mode = 'production';
config["performance"] = {//打包文件大小配置
"maxEntrypointSize": 900000000,
"maxAssetSize": 90000000,
"hints": false
}
}
config.optimization = {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
maxSize: 20000,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name (module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`
}
}
}
}
};
},