一、移除vue生产环境console.log
1.1安装插件
npm install babel-plugin-transform-remove-console --save-dev
1.2、babel.config.js配置
/**
* babel 配置
*/
const proPlugins = ["@vue/babel-plugin-transform-vue-jsx"];
// 生产环境移除console
if (process.env.NODE_ENV === "production") {
proPlugins.push("transform-remove-console");
}
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
// 没用不管
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: `~.qn/el-themes/${process.env.THEME || 'default'}`
}
],
...proPlugins
]
}
二、本地打包测试
2.1安装插件
npm install http-server -g
2.2、打包完成后运行命令
http-server ./dist
注意
重启http-server时,注意端口关了并且浏览器清理缓存,不然总是请求之前的页面