2026-09-25 17:12:58 +00:00
|
|
|
import {builtinModules} from "module"
|
|
|
|
|
import {fileURLToPath} from "url"
|
|
|
|
|
import {config} from "dotenv"
|
|
|
|
|
import {defineConfig} from "vite"
|
|
|
|
|
|
|
|
|
|
config({path: ".env.local"})
|
|
|
|
|
config({path: ".env"})
|
2026-05-15 09:23:15 +00:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
2026-09-25 17:12:58 +00:00
|
|
|
// The production image has no .env beside the bundle, so branding travels inside the bundle.
|
|
|
|
|
define: Object.fromEntries(
|
|
|
|
|
Object.keys(process.env)
|
|
|
|
|
.filter(key => key.startsWith("VITE_"))
|
|
|
|
|
.map(key => [`process.env.${key}`, JSON.stringify(process.env[key])]),
|
|
|
|
|
),
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"isomorphic-ws": fileURLToPath(new URL("server/websocket.js", import.meta.url)),
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-05-15 09:23:15 +00:00
|
|
|
ssr: {
|
|
|
|
|
noExternal: true, // bundle every dependency
|
|
|
|
|
},
|
|
|
|
|
build: {
|
2026-09-25 17:12:58 +00:00
|
|
|
target: "node24", // match your Node.js version
|
|
|
|
|
outDir: "build-server",
|
|
|
|
|
emptyOutDir: false, // don't wipe the frontend build output
|
|
|
|
|
ssr: true, // tells Vite this is a server-side build
|
|
|
|
|
minify: "esbuild", // minify the output
|
2026-05-15 09:23:15 +00:00
|
|
|
lib: {
|
2026-09-25 17:12:58 +00:00
|
|
|
entry: "server.js", // your server entry point
|
|
|
|
|
formats: ["es"],
|
|
|
|
|
fileName: () => "server.js",
|
2026-05-15 09:23:15 +00:00
|
|
|
},
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
// Externalize only Node.js built-ins, bundle everything else
|
2026-09-25 17:12:58 +00:00
|
|
|
external: [...builtinModules, ...builtinModules.map(m => `node:${m}`)],
|
2026-05-15 09:23:15 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|