1.0.7 • Published 1 year ago

babel-plugin-transform-remove-consoles v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

babel-plugin-transform-remove-consoles

项目全局去除console的插件

Example

本地代码

var a = 1
console.log("foo");
console.error("bar");

打包后代码

var a = 1

安装插件

npm install babel-plugin-transform-remove-consoles -D

使用

babel.config.js

{
  "plugins": ["transform-remove-consoles"]
}

添加配置参数

{
  "plugins": [["transform-remove-consoles",{
    "exclude":["error","warn"],
    "env":'production',
    "commentWords":['no remove']
  }]]
}

文档

参数类型默认值介绍
excludeArray[]需要被保留的console类型
envStringproduction默认生产移除
commentWordsArray'no remove','reserve'在需要不被的console前面以后或者末尾添加

案例

1、配置exclude:'error'

本地环境

console.log('end');
console.error('end');
console.error('21212');

生产环境

console.error('end');
console.error('21212');

2、配置commentWords:'no remove console'

本地环境

console.log('start');
console.log('end');  // reserve
// no remove console
console.error('end');
// no remove
console.error('21212');

生产环境

console.log('end');  // reserve
// no remove console
console.error('end');
// no remove
console.error('21212');
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago