1.vue.config.js
const TerserPlugin = require("terser-webpack-plugin");
configureWebpack: (config) => {
if (process.env.NODE_ENV === "production") {
config.plugins.push(
//去掉打包之后的打印
new TerserPlugin({
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: {
drop_console: true,
drop_debugger: false,
pure_funcs: ["console.log"], // 移除console
},
},
})
);
} else {
// 为开发环境修改配置...
}
},