-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-router.config.ts
More file actions
49 lines (41 loc) · 1.55 KB
/
react-router.config.ts
File metadata and controls
49 lines (41 loc) · 1.55 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
40
41
42
43
44
45
46
47
48
49
import type { Config } from "@react-router/dev/config";
import { GAME_LIST } from "./src/games-list.ts";
import { parseSchemas, type SchemasJson } from "./src/data/schemas.ts";
import { readGzippedJson } from "./scripts/lib/read-gzipped-json.ts";
const isDev = process.argv.includes("dev");
export default {
ssr: false,
appDirectory: "src",
basename: "/SchemaExplorer/",
prerender: isDev
? false
: {
unstable_concurrency: 8,
async paths({ getStaticPaths }) {
const paths = [...getStaticPaths(), "/"];
for (const game of GAME_LIST) {
paths.push(`/${game.id}`);
const data = await readGzippedJson<SchemasJson>(`schemas/${game.id}.json.gz`);
const { declarations } = parseSchemas(data);
const limit = process.env.PRERENDER_ALL ? 0 : 10;
let count = 0;
for (const [mod, moduleMap] of declarations) {
paths.push(`/${game.id}/${mod}`);
if (!limit || count < limit) {
for (const name of moduleMap.keys()) {
if (process.platform === "win32" && name.includes("::")) continue;
paths.push(`/${game.id}/${mod}/${name}`);
if (limit && ++count >= limit) break;
}
}
}
if (limit) {
console.log(
`Prerender limited to ${limit} pages per game, set PRERENDER_ALL=1 to generate all pages`,
);
}
}
return paths;
},
},
} satisfies Config;