vite.config.ts 1.37 KB
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'node:path'

// vibe_erp web SPA — Vite config.
//
// **Why this lives at web/, not under platform-bootstrap/static/**
// Keeping the SPA in its own directory means a frontend dev can run
// `npm run dev` (Vite dev server on :5173) without touching the JVM
// build, while the production build pipeline drops the static bundle
// into distribution/src/main/resources/static/ for Spring Boot to
// serve. The Gradle wrapper task in web/build.gradle.kts is what
// glues `npm run build` into `./gradlew build` so a normal CI run
// produces a single fat-jar that already contains the SPA.
//
// **Dev proxy.** During `npm run dev` the Vite server proxies every
// /api/v1/** call to the locally-running Spring Boot at :8080 so
// the SPA dev experience is "edit a .tsx file, save, hot-reload,
// the same JWT keeps working against the real backend". The proxy
// is dev-only — in the production bundle the SPA and API live on
// the same origin so no proxy is needed.
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
      },
    },
  },
  build: {
    outDir: 'dist',
    sourcemap: true,
  },
})