/ vite.config.ts
vite.config.ts
1 import { defineConfig } from 'vite' 2 import { devtools } from '@tanstack/devtools-vite' 3 import basicSsl from '@vitejs/plugin-basic-ssl' 4 import tsconfigPaths from 'vite-tsconfig-paths' 5 6 import { tanstackStart } from '@tanstack/react-start/plugin/vite' 7 8 import viteReact from '@vitejs/plugin-react' 9 import tailwindcss from '@tailwindcss/vite' 10 11 const config = defineConfig(({ command }) => { 12 const disableTanStackDevtools = 13 process.env.VITE_DISABLE_TANSTACK_DEVTOOLS === '1' 14 // Only enable HTTPS plugins for the true dev server, not for 'preview' or 'build' 15 // where we use Caddy as a reverse proxy. 16 const isPreview = process.argv.includes('preview') 17 const enableDevHttps = process.env.VITE_DEV_HTTPS === '1' && command === 'serve' && !isPreview 18 19 return { 20 server: enableDevHttps 21 ? { 22 https: {}, 23 } 24 : undefined, 25 preview: { 26 allowedHosts: true, 27 }, 28 plugins: [ 29 ...(disableTanStackDevtools ? [] : [devtools()]), 30 ...(enableDevHttps ? [basicSsl()] : []), 31 tsconfigPaths({ projects: ['./tsconfig.json'] }), 32 tailwindcss(), 33 tanstackStart(), 34 viteReact(), 35 ], 36 } 37 }) 38 39 export default config