Skip to content

Commit 1056d1e

Browse files
committed
fix remote source maps for users with custom ghp domains
1 parent c30f8ec commit 1056d1e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

webpack/webpack.prod.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@ const { SourceMapDevToolPlugin } = require('webpack');
33
const { merge } = require('webpack-merge');
44
const common = require('./webpack.common.js');
55

6-
function createGHPSourceMapURL(env) {
6+
async function createGHPSourceMapURL(env) {
77
const manifest = require("../manifest/manifest.json");
88
const version = manifest.version;
99
const [owner, repo_name] = (process.env.GITHUB_REPOSITORY ?? "ajayyy/SponsorBlock").split("/");
10-
return `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`;
10+
const ghpUrl = `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`;
11+
// make a request to the url and check if we got redirected
12+
// firefox doesn't seem to like getting redirected on a source map request
13+
try {
14+
const resp = await fetch(ghpUrl);
15+
return resp.url;
16+
} catch {
17+
return ghpUrl;
18+
}
1119
}
1220

13-
module.exports = env => {
21+
module.exports = async env => {
1422
let mode = "production";
1523
env.mode = mode;
1624

@@ -20,7 +28,7 @@ module.exports = env => {
2028
? {
2129
devtool: false,
2230
plugins: [new SourceMapDevToolPlugin({
23-
publicPath: createGHPSourceMapURL(env),
31+
publicPath: await createGHPSourceMapURL(env),
2432
filename: '[file].map[query]',
2533
})],
2634
}

0 commit comments

Comments
 (0)