-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbabel.config.js
43 lines (37 loc) · 1.13 KB
/
babel.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const inProduction = process.env.NODE_ENV === 'production';
module.exports = api => {
api.cache.using(() => process.env.NODE_ENV);
const config = {
presets: [
'module:metro-react-native-babel-preset',
process.env.NODE_ENV === 'test' && ['@babel/preset-env', { targets: { node: 'current' } }],
].filter(preset => preset),
plugins: [
'module:react-native-dotenv',
'@babel/plugin-proposal-optional-chaining',
['@babel/plugin-proposal-decorators', { legacy: true }],
'transform-class-properties',
[
'module-resolver',
{
root: ['./src'],
alias: {
api: './src/services/api',
},
extensions: ['.js', '.jsx', '.ts', '.tsx', '.android.js', '.android.tsx', '.ios.js', '.ios.tsx'],
},
],
],
};
if (inProduction && !process.env.RN_SRC_EXT?.includes('e2e')) {
config.plugins.push([
'babel-plugin-jsx-remove-data-test-id',
{
attributes: 'testID',
},
]);
}
// Reanimated plugin has to be listed last.
config.plugins.push('react-native-reanimated/plugin');
return config;
};