forked from expo/expo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetro.config.js
More file actions
32 lines (25 loc) · 1.09 KB
/
Copy pathmetro.config.js
File metadata and controls
32 lines (25 loc) · 1.09 KB
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
const { createMetroConfiguration } = require('expo-yarn-workspaces');
const baseConfig = createMetroConfiguration(__dirname);
module.exports = {
...baseConfig,
// NOTE(brentvatne): This can be removed when
// https://github.com/facebook/metro/issues/290 is fixed.
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);
};
},
},
};