forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metro.config.js
45 lines (42 loc) · 1.6 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
39
40
41
42
43
44
45
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*/
const {getDefaultConfig} = require('metro-config');
const _ = require('underscore');
require('dotenv').config();
/* eslint arrow-body-style: 0 */
module.exports = (() => {
const isUsingMockAPI = process.env.E2E_TESTING === 'true';
if (isUsingMockAPI) {
// eslint-disable-next-line no-console
console.warn('⚠️ Using mock API');
}
return getDefaultConfig().then((config) => {
return {
resolver: {
assetExts: _.filter(config.resolver.assetExts, (ext) => ext !== 'svg'),
sourceExts: ['jsx', 'js', 'ts', 'tsx', 'json', 'svg'],
resolveRequest: (context, moduleName, platform) => {
const resolution = context.resolveRequest(context, moduleName, platform);
if (isUsingMockAPI && moduleName.includes('/API')) {
return {
...resolution,
filePath: resolution.filePath.replace(/src\/libs\/API.js/, 'src/libs/E2E/API.mock.js'),
};
}
return resolution;
},
},
transformer: {
getTransformOptions: () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
};
});
})();