You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.1 KiB
86 lines
2.1 KiB
const path = require('path');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
|
|
module.exports = {
|
|
devServer: {
|
|
proxy: {
|
|
'/supernew': {
|
|
target: 'http://adminnew.pengda.checkcopy.com/',
|
|
changeOrigin: true,
|
|
},
|
|
'/agentnew': {
|
|
target: 'http://kuaile.checkcopy.com',
|
|
changeOrigin: true,
|
|
}
|
|
}
|
|
},
|
|
configureWebpack: {
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.m?js$/,
|
|
exclude: /(node_modules|bower_components)/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
plugins: [
|
|
'@babel/plugin-proposal-optional-chaining', // 支持 ?.
|
|
// '@babel/plugin-proposal-nullish-coalescing-operator' // 支持 ??
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
optimization: {
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
terserOptions: {
|
|
format: {
|
|
comments: /^\**!|@preserve|@license|@cc_on/i
|
|
},
|
|
compress: {
|
|
drop_console: process.env.NODE_ENV === 'production' // 生产环境移除 console
|
|
}
|
|
},
|
|
extractComments: false
|
|
})
|
|
]
|
|
},
|
|
output: {
|
|
filename: '[name].[contenthash:8].js',
|
|
chunkFilename: '[name].[contenthash:8].js'
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src/')
|
|
}
|
|
}
|
|
},
|
|
chainWebpack: config => {
|
|
// 关键配置:让 Babel 处理 Vue 模板中的现代语法
|
|
config.module
|
|
.rule('vue')
|
|
.use('vue-loader')
|
|
.tap(options => {
|
|
options.compilerOptions = {
|
|
...(options.compilerOptions || {}),
|
|
whitespace: 'condense',
|
|
preserveWhitespace: false,
|
|
// 允许模板中使用现代 JS 语法(如 ?.)
|
|
transpileOptions: {
|
|
transforms: {
|
|
dangerousTaggedTemplateString: true,
|
|
modules: false
|
|
}
|
|
}
|
|
};
|
|
return options;
|
|
});
|
|
|
|
// 生产环境配置
|
|
if (process.env.NODE_ENV === 'production') {
|
|
config.optimization.minimize(true);
|
|
}
|
|
}
|
|
};
|