|
1 | | -// Learn more https://docs.expo.io/guides/customizing-metro |
2 | 1 | const { getDefaultConfig } = require('expo/metro-config'); |
3 | 2 | const { withNativeWind } = require('nativewind/metro'); |
4 | | -const { FileStore } = require('metro-cache'); |
5 | 3 | const path = require('path'); |
6 | 4 |
|
7 | 5 | // Find the project and workspace directories |
8 | 6 | const projectRoot = __dirname; |
9 | 7 | // This can be replaced with `find-yarn-workspace-root` |
10 | 8 | const monorepoRoot = path.resolve(projectRoot, '../..'); |
11 | 9 |
|
12 | | -/** @type {import('expo/metro-config').MetroConfig} */ |
13 | | -const config = getDefaultConfig(__dirname, { |
14 | | - // [Web-only]: Enables CSS support in Metro. |
15 | | - isCSSEnabled: true, |
16 | | -}); |
| 10 | +const config = getDefaultConfig(projectRoot); |
17 | 11 |
|
18 | | -// #1 - Watch all files in the monorepo |
| 12 | +// 1. Watch all files within the monorepo |
19 | 13 | config.watchFolders = [monorepoRoot]; |
20 | | -// #3 - Force resolving nested modules to the folders below |
21 | | -config.resolver.disableHierarchicalLookup = true; |
22 | | -// #2 - Try resolving with project modules first, then workspace modules |
| 14 | +// 2. Let Metro know where to resolve packages and in what order |
23 | 15 | config.resolver.nodeModulesPaths = [ |
24 | 16 | path.resolve(projectRoot, 'node_modules'), |
25 | 17 | path.resolve(monorepoRoot, 'node_modules'), |
26 | 18 | ]; |
27 | 19 |
|
28 | | -// Use turborepo to restore the cache when possible |
29 | | -config.cacheStores = [ |
30 | | - new FileStore({ root: path.join(projectRoot, 'node_modules', '.cache', 'metro') }), |
31 | | -]; |
32 | | - |
33 | 20 | const { resolver } = config; |
34 | 21 | config.resolver = { |
35 | 22 | ...resolver, |
|
0 commit comments