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 outDir: process.env.E2E_DIST_DIR ?? 'dist',
25 cssCodeSplit,
26 },
27 plugins: [
28 // Nitro is placed BEFORE tanstackStart to test that our CSS middleware
29 // works regardless of plugin order (nitro has a catch-all middleware)
30 ...nitroPlugin,
31 tanstackStart(),
32 viteReact(),
33 ],
34 }
35})