From 32a7d23dc97e74f723e40f2874e24673b4454a4c Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sat, 13 Mar 2021 18:27:44 +0100 Subject: [PATCH] Fixed #61 --- babel.config.js | 46 ++++++++++++++++++++++++++++------------------ package.json | 3 ++- yarn.lock | 5 +++++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/babel.config.js b/babel.config.js index 71b5eb8a..dd162868 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,24 +1,34 @@ module.exports = function (api) { api.cache(true) + + const plugins = [ + '@babel/plugin-proposal-optional-chaining', + [ + 'module-resolver', + { + root: ['./'], + alias: { + '@assets': './assets', + '@root': './src', + '@api': './src/api', + '@components': './src/components', + '@screens': './src/screens', + '@utils': './src/utils' + } + } + ], + 'react-native-reanimated/plugin' + ] + + if ( + process.env.NODE_ENV === 'production' || + process.env.BABEL_ENV === 'production' + ) { + plugins.push('transform-remove-console') + } + return { presets: ['babel-preset-expo'], - plugins: [ - '@babel/plugin-proposal-optional-chaining', - [ - 'module-resolver', - { - root: ['./'], - alias: { - '@assets': './assets', - '@root': './src', - '@api': './src/api', - '@components': './src/components', - '@screens': './src/screens', - '@utils': './src/utils' - } - } - ], - 'react-native-reanimated/plugin' - ] + plugins } } diff --git a/package.json b/package.json index 897786ed..032e317f 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "@welldone-software/why-did-you-render": "^6.0.5", "babel-jest": "~25.2.6", "babel-plugin-module-resolver": "^4.1.0", + "babel-plugin-transform-remove-console": "^6.9.4", "chalk": "^4.1.0", "dotenv": "^8.2.0", "jest": "^26.6.3", @@ -119,4 +120,4 @@ "typescript": "~4.1.3", "uri-scheme": "^1.0.67" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index b40bf6d2..4997f463 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3124,6 +3124,11 @@ babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0: resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf" integrity sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ== +babel-plugin-transform-remove-console@^6.9.4: + version "6.9.4" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz#b980360c067384e24b357a588d807d3c83527780" + integrity sha1-uYA2DAZzhOJLNXpYjYB9PINSd4A= + babel-preset-current-node-syntax@^0.1.2: version "0.1.4" resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.4.tgz#826f1f8e7245ad534714ba001f84f7e906c3b615"