x-php-Admin/vue.config.js

74 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-07-28 16:35:45 +00:00
const {
defineConfig
} = require('@vue/cli-service')
2023-09-11 11:06:27 +00:00
const TerserPlugin = require('terser-webpack-plugin');
2023-07-28 16:35:45 +00:00
module.exports = defineConfig({
//设置为空打包后不分更目录还是多级目录
2023-09-04 08:13:49 +00:00
publicPath: process.env.PUBLIC_PATH,
2023-07-28 16:35:45 +00:00
//build编译后存放静态文件的目录
assetsDir: "static",
// build编译后不生成资源MAP文件
productionSourceMap: false,
//开发服务,build后的生产模式还需nginx代理
chainWebpack: config => {
// 移除 prefetch 插件
config.plugins.delete('preload');
config.plugins.delete('prefetch');
config.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js');
},
configureWebpack: {
output: {
// filename: 'app.[contenthash].js',
},
//性能提示
performance: {
hints: false
},
optimization: {
2023-09-11 11:06:27 +00:00
// 去除生产环境中的 console 输出
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true
}
}
})
],
2023-07-28 16:35:45 +00:00
splitChunks: {
chunks: "all",
automaticNameDelimiter: '~',
name: "xChunks",
cacheGroups: {
//第三方库抽离
vendor: {
name: "modules",
test: /[\\/]node_modules[\\/]/,
priority: -10
},
elicons: {
name: "elicons",
test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
},
tinymce: {
name: "tinymce",
test: /[\\/]node_modules[\\/]tinymce[\\/]/
},
echarts: {
name: "echarts",
test: /[\\/]node_modules[\\/]echarts[\\/]/
},
xgplayer: {
name: "xgplayer",
test: /[\\/]node_modules[\\/]xgplayer.*[\\/]/
},
codemirror: {
name: "codemirror",
test: /[\\/]node_modules[\\/]codemirror[\\/]/
}
}
}
}
}
})