1const { createMetroConfiguration } = require('expo-yarn-workspaces'); 2 3const baseConfig = createMetroConfiguration(__dirname); 4 5module.exports = { 6 ...baseConfig, 7 8 // NOTE(brentvatne): This can be removed when 9 // https://github.com/facebook/metro/issues/290 is fixed. 10 server: { 11 enhanceMiddleware: middleware => { 12 return (req, res, next) => { 13 // When an asset is imported outside the project root, it has wrong path on Android 14 // This happens for the back button in stack, so we fix the path to correct one 15 const assets = '/node_modules/@react-navigation/stack/src/views/assets'; 16 17 if (req.url.startsWith(assets)) { 18 req.url = req.url.replace(assets, `/assets/../..${assets}`); 19 } 20 21 return middleware(req, res, next); 22 }; 23 }, 24 }, 25}; 26