-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmetro.js
More file actions
34 lines (26 loc) · 776 Bytes
/
Copy pathmetro.js
File metadata and controls
34 lines (26 loc) · 776 Bytes
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 withShareExtension = (config) => {
if (!config.resolver) {
throw new Error("config.resolver is not defined");
}
config.resolver.sourceExts = [
...(config.resolver?.sourceExts ?? []),
"share.js",
];
if (!config.server) {
throw new Error("config.server is not defined");
}
const originalRewriteRequestUrl =
config.server?.rewriteRequestUrl || ((url) => url);
config.server.rewriteRequestUrl = (url) => {
const isShareExtension = url.includes("shareExtension=true");
const rewrittenUrl = originalRewriteRequestUrl(url);
if (isShareExtension) {
return rewrittenUrl.replace("index.bundle", "index.share.bundle");
}
return rewrittenUrl;
};
return config;
};
module.exports = {
withShareExtension,
};