Setup react native web

This commit is contained in:
2026-05-28 12:49:58 +02:00
parent 466b792878
commit 0ac36e9890
6 changed files with 755 additions and 31 deletions
+18 -1
View File
@@ -2,6 +2,8 @@ const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
const path = require("node:path");
const root = path.resolve(__dirname, "..");
const useWeb = process.env.USE_WEB === "true" || process.env.PLATFORM === "web";
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
@@ -9,7 +11,22 @@ const root = path.resolve(__dirname, "..");
* @type {import('metro-config').MetroConfig}
*/
const config = {
watchFolders: [root],
watchFolders: [root],
...(useWeb && {
resolver: {
extraNodeModules: {
"react-native": path.resolve(__dirname, "node_modules", "react-native-web"),
},
},
}),
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config);