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

vite.config.ts

39 lines1.1 KB

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