forked from slopus/happy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbabel.config.js
More file actions
33 lines (30 loc) · 1.05 KB
/
Copy pathbabel.config.js
File metadata and controls
33 lines (30 loc) · 1.05 KB
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
module.exports = function (api) {
api.cache(true);
// Determine which worklets plugin to use based on installed versions
// Reanimated v4+ uses react-native-worklets/plugin
// Reanimated v3.x uses react-native-reanimated/plugin
let workletsPlugin = 'react-native-worklets/plugin';
try {
const reanimatedVersion = require('react-native-reanimated/package.json').version;
const majorVersion = parseInt(reanimatedVersion.split('.')[0], 10);
// For Reanimated v3.x, use the old plugin
if (majorVersion < 4) {
workletsPlugin = 'react-native-reanimated/plugin';
}
} catch (e) {
// If reanimated isn't installed, default to newer plugin
// This won't cause issues since the plugin won't be needed anyway
}
return {
presets: ['babel-preset-expo'],
env: {
production: {
plugins: ["transform-remove-console"],
},
},
plugins: [
['react-native-unistyles/plugin', { root: 'sources' }],
workletsPlugin // Must be last - automatically selects correct plugin for version
],
};
};