Refactor sourcemap path fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Manuel Thalmann 2022-12-04 19:08:33 +01:00
parent 40b069b632
commit 9444dddd49

View file

@ -3,7 +3,7 @@ import { dirname, isAbsolute, relative, resolve } from "path";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
import exports, { Configuration } from "webpack"; import exports, { Configuration } from "webpack";
const { WatchIgnorePlugin, SourceMapDevToolPlugin } = exports; const { WatchIgnorePlugin } = exports;
let dirName = fileURLToPath(new URL(".", import.meta.url)); let dirName = fileURLToPath(new URL(".", import.meta.url));
@ -36,16 +36,7 @@ let generator = (env: any, argv: any): Configuration[] =>
} }
else else
{ {
let fallback = new SourceMapDevToolPlugin().moduleFilenameTemplate; return `webpack://${context.namespace}/${context.resourcePath}${context.loaders === "" ? "" : `?${context.loaders}`}`;
if (typeof fallback === "function")
{
return fallback(context);
}
else
{
return fallback;
}
} }
}, },
libraryTarget: "module", libraryTarget: "module",
@ -102,6 +93,8 @@ let generator = (env: any, argv: any): Configuration[] =>
sourceMap.sources = sourceMap.sources.map( sourceMap.sources = sourceMap.sources.map(
(source: string) => (source: string) =>
{ {
console.log(source);
// Prevent `webpack://` sources from being changed // Prevent `webpack://` sources from being changed
if (isAbsolute(source)) if (isAbsolute(source))
{ {