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

export default defineConfig({
  plugins: [
    react(),
    tailwindcss(),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '@lib': path.resolve(__dirname, './src/lib'),
      '@shared': path.resolve(__dirname, './src/shared'),
      '@features': path.resolve(__dirname, './src/features'),
      '@data': path.resolve(__dirname, './src/data'),
      '@stores': path.resolve(__dirname, './src/stores'),
    },
  },
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: process.env.VITE_API_PROXY ?? 'https://kcg-ai-monitoring.gc-si.dev',
        changeOrigin: true,
        secure: false,
        headers: {
          Origin: process.env.VITE_API_PROXY ?? 'https://kcg-ai-monitoring.gc-si.dev',
        },
      },
    },
  },
  build: {
    rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'index.html'),
        systemFlow: path.resolve(__dirname, 'system-flow.html'),
        designSystem: path.resolve(__dirname, 'design-system.html'),
      },
    },
  },
})
