import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { readFileSync } from "node:fs"; // Bake the package.json version into the bundle so the running SPA can compare // it to the server's X-App-Version header and detect a new deploy. const appVersion = ( JSON.parse(readFileSync("./package.json", "utf8")) as { version: string } ).version; export default defineConfig({ plugins: [react()], root: ".", publicDir: "public", define: { __APP_VERSION__: JSON.stringify(appVersion), }, server: { port: 3000, }, build: { outDir: "dist-client", emptyOutDir: true, sourcemap: false, target: "es2020", rollupOptions: { output: { manualChunks(id: string) { if ( id.includes("node_modules/react") || id.includes("node_modules/react-dom") || id.includes("node_modules/react-router") ) { return "vendor-react"; } if (id.includes("node_modules/framer-motion")) { return "vendor-animation"; } }, }, }, }, });