2022-08-09 03:29:14 +00:00
|
|
|
const { makeMetroConfig, resolveUniqueModule, exclusionList } = require('@rnx-kit/metro-config');
|
|
|
|
|
2022-10-17 13:27:14 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
2022-08-09 03:29:14 +00:00
|
|
|
// Needed for transforming svgs from @sd/assets
|
|
|
|
const [reactSVGPath, reactSVGExclude] = resolveUniqueModule('react-native-svg');
|
|
|
|
|
|
|
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
|
|
const expoDefaultConfig = getDefaultConfig(__dirname);
|
|
|
|
|
2022-10-17 13:27:14 +00:00
|
|
|
const projectRoot = __dirname;
|
|
|
|
const workspaceRoot = path.resolve(projectRoot, '../..');
|
|
|
|
|
2022-08-09 03:29:14 +00:00
|
|
|
const metroConfig = makeMetroConfig({
|
2022-10-17 13:27:14 +00:00
|
|
|
projectRoot,
|
|
|
|
watchFolders: [workspaceRoot],
|
2022-08-09 03:29:14 +00:00
|
|
|
resolver: {
|
|
|
|
...expoDefaultConfig.resolver,
|
|
|
|
extraNodeModules: {
|
|
|
|
'react-native-svg': reactSVGPath
|
|
|
|
},
|
2022-11-01 13:32:56 +00:00
|
|
|
blockList: exclusionList([reactSVGExclude]),
|
2022-08-09 03:29:14 +00:00
|
|
|
sourceExts: [...expoDefaultConfig.resolver.sourceExts, 'svg'],
|
2022-10-17 13:27:14 +00:00
|
|
|
assetExts: expoDefaultConfig.resolver.assetExts.filter((ext) => ext !== 'svg'),
|
|
|
|
disableHierarchicalLookup: true,
|
|
|
|
nodeModulesPaths: [
|
|
|
|
path.resolve(projectRoot, 'node_modules'),
|
|
|
|
path.resolve(workspaceRoot, 'node_modules')
|
|
|
|
]
|
2022-08-09 03:29:14 +00:00
|
|
|
},
|
|
|
|
transformer: {
|
|
|
|
// Metro default is "uglify-es" but terser should be faster and has better defaults.
|
|
|
|
minifierPath: 'metro-minify-terser',
|
|
|
|
minifierConfig: {
|
|
|
|
compress: {
|
|
|
|
drop_console: true,
|
|
|
|
// Sometimes improves performance?
|
|
|
|
reduce_funcs: false
|
|
|
|
},
|
|
|
|
format: {
|
|
|
|
ascii_only: true,
|
|
|
|
wrap_iife: true,
|
|
|
|
quote_style: 3
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getTransformOptions: async () => ({
|
|
|
|
transform: {
|
|
|
|
experimentalImportSupport: false,
|
|
|
|
inlineRequires: true
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
babelTransformerPath: require.resolve('react-native-svg-transformer')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = metroConfig;
|