import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  test: {
    environment: 'jsdom',
    setupFiles: './src/test/setup.ts',
    clearMocks: true,
  },
  server: {
    proxy: {
      // ponytail: the deployed nginx injects the Authorization header, so dev can
      // point at it (DEV_API_TARGET=http://localhost:5174) instead of a bare backend.
      '/api': process.env.DEV_API_TARGET || 'http://localhost:3000',
    }
  },
  build: {
    outDir: 'dist',
    emptyOutDir: true,
  }
})
