-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmetro.config.js
More file actions
78 lines (74 loc) · 2.42 KB
/
metro.config.js
File metadata and controls
78 lines (74 loc) · 2.42 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
/* eslint-disable global-require */
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
const { mergeConfig, getDefaultConfig } = require("@react-native/metro-config");
const { withSentryConfig } = require("@sentry/react-native/metro");
const { withNativeWind } = require("nativewind/metro");
const {
wrapWithReanimatedMetroConfig,
} = require("react-native-reanimated/metro-config");
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('@react-native/metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve("react-native-svg-transformer"),
minifierConfig: {
// Terser minification options for production builds
compress: {
drop_console: true, // Remove console.log statements
drop_debugger: true, // Remove debugger statements
pure_funcs: [
"console.log",
"console.info",
"console.debug",
"console.warn",
],
},
mangle: {
toplevel: true, // Mangle top-level variable names
},
output: {
comments: false, // Remove all comments
ascii_only: true, // Escape Unicode characters
},
},
},
resolver: {
assetExts: ["png", "jpg", "jpeg", "gif"],
sourceExts: ["js", "jsx", "ts", "tsx", "svg", "json", "cjs"],
extraNodeModules: require("node-libs-react-native"),
unstable_enablePackageExports: false,
unstable_enableSymlinks: false,
resolveRequest: (context, moduleName, platform) => {
// Handle @noble/hashes crypto.js import
if (moduleName === "@noble/hashes/crypto.js") {
return {
filePath: require.resolve("@noble/hashes/crypto.js"),
type: "sourceFile",
};
}
// Handle multiformats cjs imports
if (moduleName.startsWith("multiformats/cjs/")) {
const path = moduleName.replace("multiformats/cjs/", "");
return {
filePath: require.resolve(`multiformats/cjs/src/${path}`),
type: "sourceFile",
};
}
return context.resolveRequest(context, moduleName, platform);
},
},
};
module.exports = withSentryConfig(
wrapWithReanimatedMetroConfig(
withNativeWind(mergeConfig(getDefaultConfig(__dirname), config), {
input: "./global.css",
}),
),
{ annotateReactComponents: true },
);