forked from Shelf-nu/shelf.nu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-router.config.ts
More file actions
39 lines (38 loc) · 1.13 KB
/
react-router.config.ts
File metadata and controls
39 lines (38 loc) · 1.13 KB
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
35
36
37
38
39
import type { Config } from "@react-router/dev/config";
import esbuild from "esbuild";
import fs from "node:fs";
import path from "node:path";
export default {
ssr: true,
buildEnd: async ({ reactRouterConfig }) => {
const sentryInstrument = `instrument.server`;
await esbuild
.build({
alias: {
"~": `./app`,
},
outdir: `${reactRouterConfig.buildDirectory}/server`,
entryPoints: [`./server/${sentryInstrument}.ts`],
platform: "node",
format: "esm",
// Don't include node_modules in the bundle
packages: "external",
bundle: true,
logLevel: "info",
})
.then(() => {
const serverBuildPath = `${reactRouterConfig.buildDirectory}/server/${reactRouterConfig.serverBuildFile}`;
fs.writeFileSync(
serverBuildPath,
Buffer.concat([
Buffer.from(`import "./${sentryInstrument}.js"\n`),
Buffer.from(fs.readFileSync(serverBuildPath)),
])
);
})
.catch((error: unknown) => {
console.error(error);
process.exit(1);
});
},
} satisfies Config;