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

vite.config.ts

41 lines1.2 KB

1import { defineConfig } from 'vite'
2import react from '@vitejs/plugin-react'
3import { tanstackRouter } from '@tanstack/router-plugin/vite'
4​
5const isVerboseFileRoutes = process.env.VERBOSE_FILE_ROUTES === '1' || false
6console.info(`Verbose file routes is set to: ${isVerboseFileRoutes}.`)
7​
8// https://vitejs.dev/config/
9export default defineConfig({
10 plugins: [
11 tanstackRouter({
12 target: 'react',
13 autoCodeSplitting: true,
14 verboseFileRoutes: isVerboseFileRoutes,
15 codeSplittingOptions: {
16 splitBehavior: ({ routeId }) => {
17 if (
18 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
19 routeId === undefined ||
20 routeId.startsWith('$$TSR_') ||
21 // @ts-expect-error
22 routeId === ''
23 ) {
24 console.error(
25 'The routeId is empty or undefined. This should not happen.',
26 )
27 process.exit(1)
28 }
29 if (routeId === '/posts') {
30 return [
31 ['loader'],
32 ['component'],
33 ['pendingComponent', 'notFoundComponent', 'errorComponent'],
34 ]
35 }
36 },
37 },
38 }),
39 react(),
40 ],
41})