1,安装:babel-plugin-transform-remove-console
npm install babel-plugin-transform-remove-console --save-dev
2,在babel.config.js文件中写入如下代码(如果没有自己创建)
const IS_PROD = ["production", "prod"].includes(process.env.NODE_ENV);
let plugins = [
[
"import",
{
libraryName: "ant-design-vue",
libraryDirectory: "es",
style: true
}
]
];
if (IS_PROD) {
plugins.push("transform-remove-console");
}
module.exports = {
presets: ["@vue/app"],
plugins
};