mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 03:27:03 +03:00
fix remote source maps for users with custom ghp domains
This commit is contained in:
@@ -3,14 +3,22 @@ const { SourceMapDevToolPlugin } = require('webpack');
|
||||
const { merge } = require('webpack-merge');
|
||||
const common = require('./webpack.common.js');
|
||||
|
||||
function createGHPSourceMapURL(env) {
|
||||
async function createGHPSourceMapURL(env) {
|
||||
const manifest = require("../manifest/manifest.json");
|
||||
const version = manifest.version;
|
||||
const [owner, repo_name] = (process.env.GITHUB_REPOSITORY ?? "ajayyy/SponsorBlock").split("/");
|
||||
return `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`;
|
||||
const ghpUrl = `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`;
|
||||
// make a request to the url and check if we got redirected
|
||||
// firefox doesn't seem to like getting redirected on a source map request
|
||||
try {
|
||||
const resp = await fetch(ghpUrl);
|
||||
return resp.url;
|
||||
} catch {
|
||||
return ghpUrl;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = env => {
|
||||
module.exports = async env => {
|
||||
let mode = "production";
|
||||
env.mode = mode;
|
||||
|
||||
@@ -20,7 +28,7 @@ module.exports = env => {
|
||||
? {
|
||||
devtool: false,
|
||||
plugins: [new SourceMapDevToolPlugin({
|
||||
publicPath: createGHPSourceMapURL(env),
|
||||
publicPath: await createGHPSourceMapURL(env),
|
||||
filename: '[file].map[query]',
|
||||
})],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user