1+ import { existsSync } from "node:fs" ;
2+ import { fileURLToPath } from "node:url" ;
3+ import { dirname , resolve } from "node:path" ;
14import { defineConfig } from "vite" ;
25import { tanstackStart } from "@tanstack/solid-start/plugin/vite" ;
36import viteSolid from "vite-plugin-solid" ;
47
8+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
9+
510const 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+
1528const 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
2037export default defineConfig ( {
0 commit comments