-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
35 lines (31 loc) · 861 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
const path = require('path');
const pak = require('../package.json');
module.exports = function (api) {
api.cache(true);
const exports = pak.exports;
if (!exports) {
throw new Error('The package.json must have a "exports" field');
}
const aliases = Object.entries(exports).reduce((acc, [_key, value]) => {
const key = _key.startsWith('.') ? _key.slice(1) : _key;
// We only care about the "source" field
if (value.source) {
const aliasName = pak.name + key;
acc[`^${aliasName}$`] = path.join(__dirname, '..', value.source);
}
return acc;
}, {});
return {
presets: ['babel-preset-expo'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: aliases,
},
],
'react-native-reanimated/plugin',
],
};
};