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

const gatewayPort = process.env.VITE_GATEWAY_PORT || '19876'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
    },
  },
  server: {
    port: 3000,
    proxy: {
      '/ws': {
        target: `ws://127.0.0.1:${gatewayPort}`,
        ws: true,
      },
      '/health': `http://127.0.0.1:${gatewayPort}`,
    },
  },
  build: {
    outDir: '../static',
    emptyOutDir: true,
  },
})
