|
diff --git a/node_modules/@remix-run/dev/compiler.js b/node_modules/@remix-run/dev/compiler.js |
|
index 9bbf9b1..783ccad 100644 |
|
--- a/node_modules/@remix-run/dev/compiler.js |
|
+++ b/node_modules/@remix-run/dev/compiler.js |
|
@@ -371,7 +371,7 @@ async function createServerBuild(config, options, assetsManifestPromiseRef) { |
|
bundle: true, |
|
logLevel: "silent", |
|
incremental: options.incremental, |
|
- sourcemap: options.sourcemap ? "inline" : false, |
|
+ sourcemap: options.sourcemap, |
|
// The server build needs to know how to generate asset URLs for imports |
|
// of CSS and other files. |
|
assetNames: "_assets/[name]-[hash]", |
|
@@ -399,9 +399,19 @@ async function writeServerBuildResult(config, outputFiles) { |
|
await fse__namespace.ensureDir(path__namespace.dirname(config.serverBuildPath)); |
|
|
|
for (let file of outputFiles) { |
|
- if (file.path === config.serverBuildPath) { |
|
- await fse__namespace.writeFile(file.path, file.contents); |
|
- break; |
|
+ if (file.path.endsWith(".js")) { |
|
+ // fix sourceMappingURL to be relative to current path instead of /build |
|
+ const filename = file.path.substring(file.path.lastIndexOf("/") + 1); |
|
+ const escapedFilename = filename.replace(/\./g, "\\."); |
|
+ const pattern = `(//# sourceMappingURL=)(.*)${escapedFilename}`; |
|
+ let contents = Buffer.from(file.contents).toString("utf-8"); |
|
+ contents = contents.replace(new RegExp(pattern), `$1${filename}`); |
|
+ await fse__namespace.writeFile(file.path, contents); |
|
+ } else if (file.path.endsWith(".map")) { |
|
+ // remove route: prefix from source filenames so breakpoints work |
|
+ let contents = Buffer.from(file.contents).toString("utf-8"); |
|
+ contents = contents.replace(/"route:/gm, '"'); |
|
+ await fse__namespace.writeFile(file.path, contents); |
|
} |
|
} |
|
} |