-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetro.config.js
More file actions
executable file
·53 lines (48 loc) · 1.42 KB
/
metro.config.js
File metadata and controls
executable file
·53 lines (48 loc) · 1.42 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');
const config = getDefaultConfig(__dirname);
// Disable minification for web builds
config.transformer = {
...config.transformer,
minifierConfig: {
compress: false,
mangle: false,
},
};
// Add support for resolving modules
config.resolver = {
...config.resolver,
nodeModulesPaths: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname),
],
// Fix for react-native-svg module resolution
sourceExts: [...(config.resolver.sourceExts || []), 'svg'],
resolverMainFields: ['react-native', 'browser', 'main'],
};
// Configure Metro for proxy deployment
config.server = {
...config.server,
enhanceMiddleware: (middleware) => {
return (req, res, next) => {
// Check if we're being accessed through the proxy
const proxyPath = req.headers['x-forwarded-prefix'];
if (proxyPath) {
// Inject base path into the HTML
const originalSend = res.send;
res.send = function(data) {
if (typeof data === 'string' && data.includes('<head>')) {
// Add base tag to make all relative URLs work
data = data.replace(
'<head>',
`<head><base href="${proxyPath}/">`
);
}
originalSend.call(this, data);
};
}
return middleware(req, res, next);
};
},
};
module.exports = config;