-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetro.config.js
More file actions
75 lines (66 loc) · 2.29 KB
/
metro.config.js
File metadata and controls
75 lines (66 loc) · 2.29 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
const { withNativeWind } = require('nativewind/metro');
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getSentryExpoConfig(__dirname);
// Expo injects this legacy watcher flag, but Metro 0.83 no longer accepts it.
if (config.watcher?.unstable_workerThreads !== undefined) {
delete config.watcher.unstable_workerThreads;
}
// Custom resolver to handle platform-specific modules
config.resolver = {
...config.resolver,
blockList: [
/node_modules\/.*\/ox\/tempo\/.*/,
],
alias: {
...config.resolver?.alias,
stream: 'stream-browserify',
crypto: 'react-native-quick-crypto',
http: 'stream-http',
https: 'https-browserify',
events: 'events',
},
resolveRequest: (context, moduleName, platform) => {
// Block browser-specific modules when building for native platforms
if (
platform !== 'web' &&
(moduleName === '@turnkey/sdk-browser' ||
moduleName === '@hpke/core' ||
moduleName === 'hpke-js' ||
moduleName === 'ws' ||
moduleName === 'react-use-intercom' ||
moduleName === 'recharts')
) {
// Return an empty module for these packages on native platforms
return {
type: 'empty',
};
}
// Handle Node.js built-ins for React Native
if (platform !== 'web') {
const nodeModuleMappings = {
stream: 'stream-browserify',
crypto: 'react-native-quick-crypto',
http: 'stream-http',
https: 'https-browserify',
events: 'events',
};
if (nodeModuleMappings[moduleName]) {
return context.resolveRequest(context, nodeModuleMappings[moduleName], platform);
}
}
if (platform === 'web' && moduleName === 'tslib') {
return context.resolveRequest(context, 'tslib/tslib.es6.js', platform);
}
// Default resolver for all other modules
return context.resolveRequest(context, moduleName, platform);
},
};
config.transformer.minifierConfig = {
compress: {
// The option below removes all console logs statements in production.
drop_console: true,
},
};
// inlineRem: NativeWind defaults to 14px on native. Set to 16 to match web rem sizing.
module.exports = withNativeWind(config, { input: './global.css', inlineRem: 16 });