import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { readFileSync } from 'node:fs'; // Shown in the header. Release builds get the git tag (APP_VERSION build argument, e.g. "v0.2"); // other builds show the package version with a "-dev" suffix. const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')); const appVersion = process.env.APP_VERSION || `v${pkg.version.replace(/\.0$/, '')}-dev`; export default defineConfig({ plugins: [react()], define: { __APP_VERSION__: JSON.stringify(appVersion), }, server: { port: 5173, proxy: { '/api': { target: 'http://localhost:8080', changeOrigin: true, ws: true, }, }, }, build: { outDir: 'dist', emptyOutDir: true, sourcemap: false, }, });