drop-console-webpack-plugin 打包移除日志console.log 支持webpack4
安装
npm install drop-console-webpack-plugin --save
github:https://github.com/Rise-Devin/drop-console-webpack-plugin
使用
const DropConsoleWebpackPlugin = require('drop-console-webpack-plugin')
plugins: [
new DropConsoleWebpackPlugin({drop_log:process.env.NODE_ENV === "production" }), //限制生产环境
// new DropConsoleWebpackPlugin() 不做环境限制,
]
Notes
if webpack version < 4 : 4.0.0>drop-console-webpack-plugin version >=3.0.0
if webpack version >= 4 : drop-console-webpack-plugin version >=4.0.0 && nodejs version > 7.6
参数
Name | type | default | Description |
---|---|---|---|
drop_log | Boolean | true | remove console.log(...) |
drop_info | Boolean | true | remove console.info(...) |
drop_warn | Boolean | false | remove console.warn(...) |
drop_error | Boolean | false | remove console.error(...) |
exclude | Array | [] | exclude chunk |
Code
new DropConsoleWebpackPlugin({
drop_log : true,
drop_info : true,
drop_warn : false,
drop_error : false,
exclude : ['manifest'], //排除不必要的chunk,减少build时间
})
网友评论