根据自己配置的环境来判断代码是否会被执行
npm i babel-plugin-env-debug
babel.config.js文件中
module.exports = {
plugins:[["env-debug",{
env: 'production'
}]]
};
在你的代码中
if (DEBUG) {
const a = 10;
const b = 10;
console.log(a + b);
}
如何使用了eslint 在.eslintrc中
module.exports = {
globals: {
DEBUG: true
}
}