-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetro.config.js
34 lines (27 loc) · 1.14 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
const { createMetroConfiguration } = require('expo-yarn-workspaces');
/* global __dirname */
const baseConfig = createMetroConfiguration(__dirname);
module.exports = {
...baseConfig,
// NOTE(brentvatne): This can be removed when
// https://github.com/facebook/metro/issues/290 is fixed.
server: {
...baseConfig.server,
enhanceMiddleware: (middleware) => {
return (req, res, next) => {
// When an asset is imported outside the project root, it has wrong path on Android
// This happens for the back button in stack, so we fix the path to correct one
const assets = '/node_modules/@react-navigation/stack/src/views/assets';
if (req.url.startsWith(assets)) {
req.url = req.url.replace(assets, `/assets/../..${assets}`);
}
// Same as above when testing anything required via Asset.downloadAsync() in test-suite
const testSuiteAssets = '/test-suite/assets/';
if (req.url.startsWith(testSuiteAssets)) {
req.url = req.url.replace(testSuiteAssets, '/assets/../test-suite/assets/');
}
return middleware(req, res, next);
};
},
},
};