Open History to see the last commit
1import { defineConfig } from 'vite'
2import { tanstackStart } from '@tanstack/react-start/plugin/vite'
3import viteReact from '@vitejs/plugin-react'
4β
5// Environment variables for different test configurations:
6// - VITE_BASE_PATH: Set to '/my-app' for basepath testing
7// - VITE_USE_NITRO: Set to 'true' to enable Nitro server
8// - VITE_CSS_CODE_SPLIT: Set to 'false' to disable CSS code splitting in prod
9const basePath = process.env.VITE_BASE_PATH
10const useNitro = process.env.VITE_USE_NITRO === 'true'
11const cssCodeSplit = process.env.VITE_CSS_CODE_SPLIT !== 'false'
12β
13export default defineConfig(async () => {
14 // Dynamically import nitro only when needed to avoid loading it when not used
15 const nitroPlugin = useNitro ? [(await import('nitro/vite')).nitro()] : []
16β
17 return {
18 resolve: { tsconfigPaths: true },
19 base: basePath,
20 server: {
21 port: 3000,
22 },
23 build: {
24 cssCodeSplit,
25 },
26 plugins: [
27 // Nitro is placed BEFORE tanstackStart to test that our CSS middleware
28 // works regardless of plugin order (nitro has a catch-all middleware)
29 ...nitroPlugin,
30 tanstackStart(),
31 viteReact(),
32 ],
33 }
34})