53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
const { defineConfig } = require('@vue/cli-service');
|
|
|
|
module.exports = defineConfig({
|
|
transpileDependencies: true,
|
|
|
|
// 生产环境不生成source map
|
|
productionSourceMap: false,
|
|
|
|
configureWebpack: {
|
|
optimization: {
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
minSize: 100000, // 增加最小分块大小到100KB
|
|
maxSize: 500000, // 增加最大分块大小到500KB
|
|
cacheGroups: {
|
|
vendors: {
|
|
name: 'chunk-vendors',
|
|
test: /[\\/]node_modules[\\/]/,
|
|
priority: -10,
|
|
chunks: 'initial'
|
|
},
|
|
common: {
|
|
name: 'chunk-common',
|
|
minChunks: 2,
|
|
priority: -20,
|
|
chunks: 'initial',
|
|
reuseExistingChunk: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
chainWebpack: config => {
|
|
// 移除 prefetch 插件,减少不必要的预加载
|
|
config.plugins.delete('prefetch');
|
|
|
|
// 简化HTML压缩
|
|
config.plugin('html').tap(args => {
|
|
args[0].minify = {
|
|
removeComments: true,
|
|
collapseWhitespace: true,
|
|
removeAttributeQuotes: true
|
|
};
|
|
return args;
|
|
});
|
|
},
|
|
|
|
css: {
|
|
extract: true,
|
|
sourceMap: false
|
|
}
|
|
}); |