Skip to content

Commit 22c0f50

Browse files
committed
disable prerender in dev
1 parent a9356e6 commit 22c0f50

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

react-router.config.ts

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,53 @@ import { GAME_LIST } from "./src/games-list.ts";
33
import { parseSchemas, type SchemasJson } from "./src/data/schemas.ts";
44
import { readGzippedJson } from "./scripts/lib/read-gzipped-json.ts";
55

6+
const isDev = process.argv.includes("dev");
7+
68
export default {
79
ssr: false,
810
appDirectory: "src",
911
basename: "/SchemaExplorer/",
10-
prerender: {
11-
unstable_concurrency: 8,
12-
async paths({ getStaticPaths }) {
13-
const paths = [...getStaticPaths(), "/"];
14-
15-
for (const game of GAME_LIST) {
16-
paths.push(`/${game.id}`);
17-
18-
const data = await readGzippedJson<SchemasJson>(`schemas/${game.id}.json.gz`);
19-
const { declarations } = parseSchemas(data);
20-
21-
const names = new Map<string, Set<string>>();
22-
for (const d of declarations) {
23-
if (!names.has(d.module)) names.set(d.module, new Set());
24-
names.get(d.module)!.add(d.name);
25-
}
26-
27-
const limit = process.env.PRERENDER_ALL ? 0 : 10;
28-
let count = 0;
29-
30-
for (const mod of names.keys()) {
31-
paths.push(`/${game.id}/${mod}`);
32-
if (!limit || count < limit) {
33-
for (const name of names.get(mod) ?? []) {
34-
if (process.platform === "win32" && name.includes("::")) continue;
35-
paths.push(`/${game.id}/${mod}/${name}`);
36-
if (limit && ++count >= limit) break;
12+
prerender: isDev
13+
? false
14+
: {
15+
unstable_concurrency: 8,
16+
async paths({ getStaticPaths }) {
17+
const paths = [...getStaticPaths(), "/"];
18+
19+
for (const game of GAME_LIST) {
20+
paths.push(`/${game.id}`);
21+
22+
const data = await readGzippedJson<SchemasJson>(`schemas/${game.id}.json.gz`);
23+
const { declarations } = parseSchemas(data);
24+
25+
const names = new Map<string, Set<string>>();
26+
for (const d of declarations) {
27+
if (!names.has(d.module)) names.set(d.module, new Set());
28+
names.get(d.module)!.add(d.name);
29+
}
30+
31+
const limit = process.env.PRERENDER_ALL ? 0 : 10;
32+
let count = 0;
33+
34+
for (const mod of names.keys()) {
35+
paths.push(`/${game.id}/${mod}`);
36+
if (!limit || count < limit) {
37+
for (const name of names.get(mod) ?? []) {
38+
if (process.platform === "win32" && name.includes("::")) continue;
39+
paths.push(`/${game.id}/${mod}/${name}`);
40+
if (limit && ++count >= limit) break;
41+
}
42+
}
43+
}
44+
45+
if (limit) {
46+
console.log(
47+
`Prerender limited to ${limit} pages per game, set PRERENDER_ALL=1 to generate all pages`,
48+
);
3749
}
3850
}
39-
}
40-
41-
if (limit) {
42-
console.log(
43-
`Prerender limited to ${limit} pages per game, set PRERENDER_ALL=1 to generate all pages`,
44-
);
45-
}
46-
}
47-
48-
return paths;
49-
},
50-
},
51+
52+
return paths;
53+
},
54+
},
5155
} satisfies Config;

0 commit comments

Comments
 (0)