Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 995 Bytes

README.md

File metadata and controls

35 lines (31 loc) · 995 Bytes

babel-plugin-code-cleaner

babel代码清洁工,删除指定的调试代码:console & debugger

插件安装

npm install babel-plugin-code-cleaner -D

babel配置

babel.config.js

{
  "plugins": ["babel-plugin-code-cleaner"]
}

添加配置参数

{
  "plugins": [["code-cleaner", {
    "env": "production", // 始终执行cleaner
    "ignoreDebug": true, // 忽略 debugger的清除
    "commentWord": "@ignore-code-cleaner" // 默认值
  }]]
}

配置项

参数类型默认值介绍
envstringenv === 'production',则始终执行cleaner
ignoreDebugbooleanfalse跳过debugger的cleaner
commentWordstring@ignore-code-cleaner遇到注释跳过cleaner,类似于 // @ts-ignore