webpack-delete-console
v1.0.0
Published
打包文件移除所有console成员方法
Downloads
3
Readme
webpack-delete-console
从webpack打包结果中移除console语句。如:console.log('日志')、console.warn('警告')等等。
安装
npm i webpack-delete-console -D
或
yarn add webpack-delete-console --dev
使用
// 引入
const DeleteConsole = require('webpack-delete-console');
// 配置
module.exports = {
// ... 其他配置 ...
plugins: [
// 可以接收一个可选参数。不传只保留warn、和error;
// 可以传一个要移除的成员方法名的数组,如: ['log', 'info', 'table', 'timeEnd', ……]
// 可传函数,调用函数时会传入匹配到的成员方法名('log'、'warn'),要移除返回true,不移除返回false
new DeleteConsole()
]
};