Template
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
import { defineConfig, loadEnv } from 'vite';
|
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
export default defineConfig(async ({ command, mode }) => {
|
|
// OPENROUTER_API_KEY and friends are server-only, so they have no VITE_
|
|
// prefix and Vite would not expose them. Load .env / .env.local into
|
|
// process.env for the server code; variables already set win.
|
|
Object.assign(process.env, loadEnv(mode, process.cwd(), ''));
|
|
|
|
return {
|
|
server: { port: 3000 },
|
|
plugins: [
|
|
// Start must come before the React plugin.
|
|
tanstackStart(),
|
|
// Hosting adapter for `vite build`: Nitro packages Start's server for the
|
|
// host (a Vercel Function when building on Vercel, a Node server in
|
|
// .output/ elsewhere). Dev never loads it, so `vite dev` — and the
|
|
// nodesandbox runtime — run plain Vite + TanStack Start + Hono.
|
|
...(command === 'build'
|
|
? [
|
|
(await import('nitro/vite')).nitro({
|
|
// Long agent runs stream for minutes (was `maxDuration` on the
|
|
// Next route).
|
|
vercel: { functions: { maxDuration: 300 } },
|
|
}),
|
|
]
|
|
: []),
|
|
react(),
|
|
tailwindcss(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
};
|
|
});
|