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,
 };

};

posted @ 2024-08-10 21:59  探出的头  阅读(4)  评论(0编辑  收藏  举报