freshyo/apps/admin-ui/metro.config.js
2026-11-18 09:40:33 +05:30

39 lines
1.6 KiB
JavaScript
Executable file

// Learn more on how to setup config for the app: https://docs.expo.dev/guides/config-plugins/#metro-config
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');
// Find the project root and workspace root
const projectRoot = __dirname;
const workspaceRoot = path.resolve(projectRoot, '../..'); // Adjust this path as needed
const config = getDefaultConfig(projectRoot);
// 1. Watch all files within the monorepo
config.watchFolders = [workspaceRoot];
// 2. Let Metro know where to resolve modules from
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, 'node_modules'),
path.resolve(workspaceRoot, 'node_modules'),
];
// 3. Keep Metro's default hierarchical lookup: forcing it off breaks packages
// that ship their own nested dependency (react-native-reanimated 4 ships a
// semver@7 used by its worklets version check, while the root has semver@6).
// 4. Ensure Metro correctly resolves the entry point for expo-router
// This is crucial for web builds in a monorepo with expo-router
config.resolver.entryExts = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs'];
// 5. Never bundle the Jest test folder (tests/). It lives outside app/, so it
// is not routed, but blocking it here makes an accidental production import
// fail loudly instead of silently shipping test code.
const escapeForRegExp = (value) =>
value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
config.resolver.blockList = [
...(config.resolver.blockList ? [].concat(config.resolver.blockList) : []),
new RegExp(`^${escapeForRegExp(path.resolve(projectRoot, 'tests'))}[/\\\\].*$`),
];
module.exports = config;