forked from wcandillon/react-native-webgpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetWebMetroConfig.js
More file actions
32 lines (27 loc) · 966 Bytes
/
getWebMetroConfig.js
File metadata and controls
32 lines (27 loc) · 966 Bytes
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
const path = require("path");
const root = path.resolve(__dirname, "../..");
const rnwPath = path.resolve(root, "node_modules/react-native-web");
const assetRegistryPath = path.resolve(
root,
"node_modules/react-native-web/dist/modules/AssetRegistry/index",
);
module.exports = function (metroConfig) {
metroConfig.resolver.platforms = ["ios", "android", "web"];
const origResolveRequest = metroConfig.resolver.resolveRequest;
metroConfig.resolver.resolveRequest = (contextRaw, moduleName, platform) => {
const context = {
...contextRaw,
preferNativePlatform: false,
};
if (moduleName === "react-native") {
return {
filePath: path.resolve(rnwPath, "dist/index.js"),
type: "sourceFile",
};
}
// Let default config handle other modules
return origResolveRequest(context, moduleName, platform);
};
metroConfig.transformer.assetRegistryPath = assetRegistryPath;
return metroConfig;
};