import { defineConfig } from 'vite'; import { tanstackStart } from '@tanstack/react-start/plugin/vite'; import { nitro } from 'nitro/vite'; import react from '@vitejs/plugin-react'; import tailwindcss from '@tailwindcss/vite'; import { fileURLToPath, URL } from 'node:url'; // Absolute origin for canonical and Open Graph URLs. Inlined at build time so // the server render and the client agree on it. Vercel provides the production // domain; set VITE_SITE_URL to override it anywhere. const siteUrl = process.env.VITE_SITE_URL ?? (process.env.VERCEL_PROJECT_PRODUCTION_URL ? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}` : 'http://localhost:3000'); export default defineConfig({ server: { port: 3000 }, plugins: [ // Start must come before the React plugin. tanstackStart(), // Builds the server for the host: Vercel's Build Output when deployed // there, a standalone Node server (.output/) everywhere else. nitro(), react(), tailwindcss(), ], define: { 'import.meta.env.VITE_SITE_URL': JSON.stringify(siteUrl), }, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, });