-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmetro.config.js
More file actions
44 lines (38 loc) · 1.35 KB
/
metro.config.js
File metadata and controls
44 lines (38 loc) · 1.35 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
const path = require('path')
const defaultConfig = getDefaultConfig(__dirname)
// Define shims statically to avoid crashing before rn-nodeify runs
const extraNodeModules = {
stream: path.resolve(__dirname, 'node_modules/stream-browserify'),
crypto: path.resolve(__dirname, 'node_modules/react-native-crypto'),
buffer: path.resolve(__dirname, 'node_modules/buffer'),
events: path.resolve(__dirname, 'node_modules/events'),
process: path.resolve(__dirname, 'node_modules/process/browser.js'),
}
const config = {
resolver: {
extraNodeModules,
resolveRequest: function packageExportsResolver(
context,
moduleImport,
platform,
) {
// Use the browser version of the package for React Native
if (moduleImport === 'axios' || moduleImport.startsWith('axios/')) {
return context.resolveRequest(
{
...context,
unstable_conditionNames: ['browser'],
},
moduleImport,
platform,
)
}
// Fall back to normal resolution
return context.resolveRequest(context, moduleImport, platform)
},
},
watchFolders: [path.resolve(__dirname, 'node_modules')],
}
module.exports = mergeConfig(defaultConfig, config)