|
1 | | -const path = require('path'); |
2 | | -// const fs = require('fs'); |
3 | 1 | const { getDefaultConfig } = require('expo/metro-config'); |
4 | 2 |
|
5 | | -const workspaceRoot = path.resolve(__dirname, '../..'); |
6 | | -// const packagesRoot = path.resolve(__dirname, '../../packages'); |
7 | | -// const docToolsRoot = path.resolve(__dirname, '../../doc-tools'); |
| 3 | +const path = require('path'); |
| 4 | +const fs = require('fs'); |
| 5 | + |
| 6 | +const projectRoot = __dirname; |
| 7 | +const packagesRoot = path.resolve(projectRoot, '../../packages'); |
| 8 | +const docToolsRoot = path.resolve(projectRoot, '../../doc-tools'); |
8 | 9 |
|
9 | | -// const packagesDirs = fs.readdirSync(packagesRoot); |
10 | | -// const docToolsDirs = fs.readdirSync(docToolsRoot); |
| 10 | +const packagesDirs = fs.readdirSync(packagesRoot); |
| 11 | +const docToolsDirs = fs.readdirSync(docToolsRoot); |
11 | 12 |
|
12 | | -// const watchFolders = [ |
13 | | -// workspaceRoot, |
14 | | -// ...packagesDirs.map((f) => path.join(packagesRoot, f)), |
15 | | -// ...docToolsDirs.map((f) => path.join(docToolsRoot, f)) |
16 | | -// ]; |
| 13 | +const config = getDefaultConfig(projectRoot); |
17 | 14 |
|
18 | | -module.exports = (async () => { |
19 | | - const { |
20 | | - resolver: { assetExts, sourceExts }, |
21 | | - transformer, |
22 | | - ...other |
23 | | - } = await getDefaultConfig(workspaceRoot); |
24 | | - return { |
25 | | - ...other, |
26 | | - resetCache: true, |
27 | | - // projectRoot: workspaceRoot, |
28 | | - // watchFolders, |
29 | | - transformer: { |
30 | | - ...transformer, |
31 | | - minifierConfig: { |
32 | | - keep_classnames: true, |
33 | | - // Need this for source mapping in @doc/pages to work. |
34 | | - keep_fnames: true, |
35 | | - mangle: { |
36 | | - keep_classnames: true, |
37 | | - // Need this for source mapping in @doc/pages to work. |
38 | | - keep_fnames: true |
39 | | - }, |
40 | | - output: { |
41 | | - ascii_only: true, |
42 | | - quote_style: 3, |
43 | | - wrap_iife: true |
44 | | - }, |
45 | | - sourceMap: { |
46 | | - includeSources: false |
47 | | - }, |
48 | | - toplevel: false, |
49 | | - compress: { |
50 | | - // reduce_funcs inlines single-use functions, which cause perf regressions. |
51 | | - reduce_funcs: false |
52 | | - } |
53 | | - }, |
54 | | - babelTransformerPath: require.resolve('react-native-svg-transformer') |
| 15 | +config.transformer = { |
| 16 | + ...config.transformer, |
| 17 | + minifierConfig: { |
| 18 | + keep_classnames: true, |
| 19 | + // Need this for source mapping in @doc/pages to work. |
| 20 | + keep_fnames: true, |
| 21 | + mangle: { |
| 22 | + keep_classnames: true, |
| 23 | + // Need this for source mapping in @doc/pages to work. |
| 24 | + keep_fnames: true |
55 | 25 | }, |
56 | | - resolver: { |
57 | | - assetExts: assetExts.filter((ext) => ext !== 'svg'), |
58 | | - sourceExts: [...sourceExts, 'svg'], |
59 | | - // extraNodeModules: new Proxy( |
60 | | - // {}, |
61 | | - // { |
62 | | - // get: (target, name) => path.join(__dirname, `node_modules/${name}`) |
63 | | - // } |
64 | | - // ) |
| 26 | + output: { |
| 27 | + ascii_only: true, |
| 28 | + quote_style: 3, |
| 29 | + wrap_iife: true |
| 30 | + }, |
| 31 | + sourceMap: { |
| 32 | + includeSources: false |
| 33 | + }, |
| 34 | + toplevel: false, |
| 35 | + compress: { |
| 36 | + // reduce_funcs inlines single-use functions, which cause perf regressions. |
| 37 | + reduce_funcs: false |
65 | 38 | } |
66 | | - }; |
67 | | -})(); |
| 39 | + }, |
| 40 | + babelTransformerPath: require.resolve('react-native-svg-transformer') |
| 41 | +}; |
| 42 | +config.resolver = { |
| 43 | + ...config.resolver, |
| 44 | + assetExts: config.resolver.assetExts.filter((ext) => ext !== 'svg'), |
| 45 | + sourceExts: [...config.resolver.sourceExts, 'svg'], |
| 46 | + nodeModulesPaths: [ |
| 47 | + ...config.resolver.nodeModulesPaths, |
| 48 | + ...packagesDirs.map((d) => |
| 49 | + path.resolve(packagesRoot, d, 'node_modules') |
| 50 | + ), |
| 51 | + ...docToolsDirs.map((d) => |
| 52 | + path.resolve(docToolsRoot, d, 'node_modules') |
| 53 | + ) |
| 54 | + ] |
| 55 | +}; |
| 56 | + |
| 57 | +module.exports = config; |
0 commit comments