-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
50 lines (45 loc) · 982 Bytes
/
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
44
45
46
47
48
49
50
const getAliasesFromTsConfig = () => {
const tsConfig = require('./tsconfig.json')
const paths = tsConfig.compilerOptions.paths
const alias = {}
Object.keys(paths).forEach(key => {
alias[key.replace(/\/\*$/, '')] = `./${paths[key][0].replace(/\/\*$/, '')}`
})
return alias
}
module.exports = api => {
api.cache(false)
const plugins = [
[
'babel-plugin-inline-import',
{
extensions: ['.svg'],
},
],
[
'babel-plugin-module-resolver',
{
alias: getAliasesFromTsConfig(),
extensions: ['.ios.js', '.android.js', '.js', '.ts', '.tsx', '.json'],
root: ['./src'],
},
],
'react-native-reanimated/plugin',
]
const presets = ['babel-preset-expo']
return {
env: {
development: {},
production: {
plugins: [
...plugins,
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-react-inline-elements',
['transform-remove-console', { exclude: ['error'] }],
],
},
},
presets,
plugins,
}
}