import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import tailwindcss from '@tailwindcss/vite';

const backendTarget = process.env.AMCS_UI_BACKEND ?? 'http://127.0.0.1:8080';

export default defineConfig({
  plugins: [svelte(), tailwindcss()],
  server: {
    host: '0.0.0.0',
    port: 5173,
    proxy: {
      '/api': backendTarget,
      '/healthz': backendTarget,
      '/readyz': backendTarget,
      '/llm': backendTarget,
      '/images': backendTarget,
      '/favicon.ico': backendTarget,
      '/mcp': backendTarget,
      '/files': backendTarget,
      '/oauth-authorization-server': backendTarget,
      '/authorize': backendTarget,
      '/oauth': backendTarget,
      '/.well-known': backendTarget
    }
  },
  build: {
    outDir: '../internal/app/ui/dist',
    emptyOutDir: true
  }
});
