react-native 设置 babel-plugin-transform-remove-console
react-native 清理console日志文件插件
babel-plugin-transform-remove-console 清理日志文件插件
安装
yarn add babel-plugin-transform-remove-console --dev
编辑babel.config.js文件
module.exports = api => {
const babelEnv = api.env();
const plugins = [];
if (babelEnv == 'production') { // production development
plugins.push(['transform-remove-console', {exclude: ['error', 'warn']}]);
}
return {
presets: ['module:metro-react-native-babel-preset'],
plugins,
};
};