-
Notifications
You must be signed in to change notification settings - Fork 1
/
metro.config.js
38 lines (31 loc) · 1.01 KB
/
metro.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
const {
resolver: { sourceExts, assetExts }
} = getDefaultConfig()
const transformerConfig = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer')
}
}
const getDefaultResolverConfig = (sourceExts, assetExts) => ({
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'jsx', 'svg']
})
const getStorybookResolverConfig = sourceExts => ({
resolverMainFields: ['sbmodern', 'react-native', 'browser', 'main'],
sourceExts: ['storybook.js', ...sourceExts]
})
const resolverConfig = process.env.STORYBOOK_ENABLED
? getStorybookResolverConfig(sourceExts)
: getDefaultResolverConfig(sourceExts, assetExts)
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
...transformerConfig,
resolver: resolverConfig
}
module.exports = mergeConfig(getDefaultConfig(__dirname), config)