Vue屏蔽打印信息
安装 npm install uglifyjs-webpack-plugin --save-dev
在vue.config.js文件或者webpack.prod.conf.js中配置
vue.config中
csharp
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
// 屏蔽打印数据
module.exports = {
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
warnings: false,
// 打包的时候移除console、debuggerdrop debugger:
drop_debugger: true,
drop_console: true,
pure_funcs: ['console.log', 'console.info']
}
})
]
}},
在第二种
csharp
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
plugins: [
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
//打包的时候移除console、debuggerdrop debugger:
drop_debugger: process.env.NODE_ENV==='production',
drop_console: process.env.NODE_ENV === 'production',
pure_funcs: ['console.log','console.info']
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
】