-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathmetro.config.js
More file actions
55 lines (49 loc) · 1.57 KB
/
metro.config.js
File metadata and controls
55 lines (49 loc) · 1.57 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
const {
wrapWithReanimatedMetroConfig
} = require('react-native-reanimated/metro-config')
const r3Paths = require('r3-hack')
const defaultConfig = getDefaultConfig(__dirname)
const { assetExts, sourceExts } = defaultConfig.resolver
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('@react-native/metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve(
'react-native-svg-transformer/react-native'
)
},
resolver: {
resolveRequest(context, moduleName, platform) {
if (platform === 'android') {
// Use Reanimated 3 on Android:
const filePath = r3Paths[moduleName]
if (filePath != null) {
return { type: 'sourceFile', filePath }
}
// Ensure we aren't missing any reanimated 3 -> 4 mappings:
if (
moduleName.startsWith('react-native-reanimated') ||
moduleName.startsWith('react-native-worklets')
) {
console.log(
`Could not find "${moduleName}". Please update r3-hack to include it.`
)
return { type: 'empty' }
}
}
// Otherwise use the normal Metro resolution:
return context.resolveRequest(context, moduleName, platform)
},
// From react-native-svg-transformer:
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg']
}
}
module.exports = wrapWithReanimatedMetroConfig(
mergeConfig(defaultConfig, config)
)