import preact from '@preact/preset-vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [preact()],
  build: {
    outDir: '../static',
    emptyOutDir: true,
    rollupOptions: {
      output: {
        // Use hashed filenames for cache busting
        entryFileNames: 'assets/[name]-[hash].js',
        chunkFileNames: 'assets/[name]-[hash].js',
        assetFileNames: 'assets/[name]-[hash].[ext]'
      }
    }
  },
  server: {
    proxy: {
      // Proxy API requests to FastAPI during development
      '/api': {
        target: 'http://localhost:8765',
        changeOrigin: true
      },
      '/health': {
        target: 'http://localhost:8765',
        changeOrigin: true
      }
    }
  }
})
