zssh-h5/vue.config.js

32 lines
1.3 KiB
JavaScript

let filePath = ''; // 默认文件路径
let TimeStamp = ''; // 时间戳
//编译环境判断,可以根据不同环境来做相应的配置
if (process.env.UNI_PLATFORM === 'h5') {
filePath = 'static/js/'
TimeStamp = new Date().getTime();
}
module.exports = {
chainWebpack: (config) => {
const isProduction = process.env.NODE_ENV === 'production'
if (isProduction) {
// 发行或运行时启用了压缩时会生效
config.optimization.minimizer('terser').tap((args) => {
const compress = args[0].terserOptions.compress
// 非 App 平台移除 console 代码(包含所有 console 方法,如 log,debug,info...)
// compress.drop_console = true
compress.pure_funcs = [
'__f__', // App 平台 vue 移除日志代码
// 'console.debug' // 可移除指定的 console 方法
]
return args
})
}
},
configureWebpack: {
output: { // filePath: 路径 name: 默认文件名 TimeStamp: 时间戳; 重构文件名
filename: `${filePath}[name]-${TimeStamp}.js`,
chunkFilename: `${filePath}[name]-${TimeStamp}.js`
},
},
}