Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

start-mode-config.ts

52 lines1.3 KB

1import { isPrerender } from './tests/utils/isPrerender'
2import { isSpaMode } from './tests/utils/isSpaMode'
3​
4const rsbuildClientOutput: 'module' | 'iife' | undefined = (() => {
5 const output = process.env.TSS_RSB_CLIENT_OUTPUT
6​
7 if (output === undefined) return undefined
8 if (output === 'module') return 'module'
9 if (output === 'iife') return 'iife'
10​
11 throw new Error(
12 `Invalid TSS_RSB_CLIENT_OUTPUT: ${output}. Expected "module" or "iife".`,
13 )
14})()
15​
16export function getStartModeConfig() {
17 return {
18 spa: isSpaMode
19 ? {
20 enabled: true,
21 prerender: {
22 outputPath: 'index.html',
23 },
24 }
25 : undefined,
26 prerender: isPrerender
27 ? {
28 enabled: true,
29 filter: (page: { path: string }) =>
30 ![
31 '/this-route-does-not-exist',
32 '/redirect',
33 '/i-do-not-exist',
34 '/not-found',
35 '/primitive-beforeload-error',
36 '/specialChars/search',
37 '/specialChars/hash',
38 '/specialChars/malformed',
39 '/users',
40 ].some((p) => page.path.includes(p)),
41 maxRedirects: 100,
42 }
43 : undefined,
44 rsbuild: rsbuildClientOutput
45 ? {
46 client: {
47 output: rsbuildClientOutput,
48 },
49 }
50 : undefined,
51 }