Skip to content

Commit 9fde982

Browse files
committed
filter prerender
1 parent 155dcb4 commit 9fde982

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

site/vite.config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
import { existsSync } from "node:fs";
2+
import { fileURLToPath } from "node:url";
3+
import { dirname, resolve } from "node:path";
14
import { defineConfig } from "vite";
25
import { tanstackStart } from "@tanstack/solid-start/plugin/vite";
36
import viteSolid from "vite-plugin-solid";
47

8+
const __dirname = dirname(fileURLToPath(import.meta.url));
9+
510
const packages = await (async () => {
611
try {
712
// @ts-ignore - generated file may not exist on a fresh checkout
@@ -12,9 +17,21 @@ const packages = await (async () => {
1217
}
1318
})();
1419

20+
// A package only gets a prerendered `/playground/<name>` page if it has a
21+
// runnable dev harness at `packages/<name>/dev/index.tsx`. `filesystem` is
22+
// additionally excluded because its dev harness imports Node-only chokidar
23+
// (mirrors the glob exclusion in src/routes/playground/$name.tsx).
24+
const hasPlayground = (name: string) =>
25+
name !== "filesystem" &&
26+
existsSync(resolve(__dirname, "..", "packages", name, "dev", "index.tsx"));
27+
1528
const prerenderPages = [
1629
"/",
17-
...packages.flatMap(({ name }) => [`/package/${name}`, `/playground/${name}`]),
30+
...packages.flatMap(({ name }) => {
31+
const paths = [`/package/${name}`];
32+
if (hasPlayground(name)) paths.push(`/playground/${name}`);
33+
return paths;
34+
}),
1835
].map(path => ({ path, prerender: { enabled: true, crawlLinks: false } }));
1936

2037
export default defineConfig({

0 commit comments

Comments
 (0)