-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmetro.config.js
More file actions
80 lines (67 loc) · 2.69 KB
/
metro.config.js
File metadata and controls
80 lines (67 loc) · 2.69 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* eslint-env node */
const _ = require('lodash');
const path = require('path');
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const { withNativeWind } = require('nativewind/metro');
const config = getSentryExpoConfig(__dirname, {
isCSSEnabled: true,
});
// Exclude electron directory from Metro bundler for Android/iOS
// Electron files use Node.js APIs that don't exist in React Native
const existingBlockList = config.resolver.blockList;
const extraBlocked = [/electron\/.*/];
config.resolver.blockList = existingBlockList
? [...(Array.isArray(existingBlockList) ? existingBlockList : [existingBlockList]), ...extraBlocked]
: extraBlocked;
// 1. Watch all files within the monorepo
// 2. Let Metro know where to resolve packages and in what order
//config.resolver.nodeModulesPaths = [path.resolve(__dirname, 'node_modules')];
// Configure path aliases
//config.resolver.extraNodeModules = {
// '@': path.resolve(__dirname, 'src'),
// '@env': path.resolve(__dirname, 'src/lib/env.js'),
// '@assets': path.resolve(__dirname, 'assets'),
//};
// Add platform-specific resolutions for web
config.resolver.resolveRequest = (context, moduleName, platform) => {
// Redirect various native module imports to our mocks on web
if (platform === 'web') {
// LiveKit WebRTC mocks
if (moduleName === '@livekit/react-native-webrtc' || moduleName === '@livekit/react-native') {
return {
type: 'empty',
};
}
// MMKV storage mock for web
if (moduleName === 'react-native-mmkv') {
return {
type: 'sourceFile',
filePath: path.resolve(__dirname, '__mocks__/react-native-mmkv.ts'),
};
}
// @gorhom/bottom-sheet depends on reanimated worklets - not available on web
if (moduleName === '@gorhom/bottom-sheet') {
return {
type: 'sourceFile',
filePath: path.resolve(__dirname, '__mocks__/@gorhom/bottom-sheet.web.js'),
};
}
// NetInfo - not needed on web, use navigator.onLine instead
if (moduleName === '@react-native-community/netinfo') {
return {
type: 'empty',
};
}
// expo-keep-awake mock for web
if (moduleName === 'expo-keep-awake') {
return {
type: 'sourceFile',
filePath: path.resolve(__dirname, '__mocks__/expo-keep-awake.ts'),
};
}
}
// Ensure you call the default resolver for all other modules
return context.resolveRequest(context, moduleName, platform);
};
config.resolver.unstable_conditionNames = _.uniq(config.resolver.unstable_conditionNames.concat('browser', 'require', 'react-native')); // <-- and here we can override what we want
module.exports = withNativeWind(config, { input: './global.css', inlineRem: 16 });