-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathmetro.config.js
More file actions
36 lines (30 loc) · 1.49 KB
/
metro.config.js
File metadata and controls
36 lines (30 loc) · 1.49 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
const path = require('path');
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname);
// Ensure shims directory is watched by Metro
config.watchFolders = [...(config.watchFolders ?? []), path.resolve(__dirname, 'shims')];
const originalResolveRequest = config.resolver.resolveRequest;
const WEB_SHIMS = {
'react-native-pager-view': 'shims/react-native-pager-view.web.tsx',
'@sentry/react-native': 'shims/sentry-react-native.web.tsx',
'@dr.pogodin/react-native-static-server': 'shims/react-native-static-server.web.ts',
'expo-network': 'shims/expo-network.web.ts',
'expo-intent-launcher': 'shims/expo-intent-launcher.web.ts',
'react-native-video': 'shims/react-native-video.web.tsx',
'expo-file-system': 'shims/expo-file-system.web.ts',
'expo-file-system/legacy': 'shims/expo-file-system.web.ts',
'expo-clipboard': 'shims/expo-clipboard.web.ts',
};
config.resolver.resolveRequest = (context, moduleName, platform) => {
if (platform === 'web' && WEB_SHIMS[moduleName]) {
return {
filePath: path.resolve(__dirname, WEB_SHIMS[moduleName]),
type: 'sourceFile',
};
}
if (originalResolveRequest) {
return originalResolveRequest(context, moduleName, platform);
}
return context.resolveRequest(context, moduleName, platform);
};
module.exports = config;