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

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '@api': path.resolve(__dirname, './src/api'),
      '@components': path.resolve(__dirname, './src/components'),
      '@hooks': path.resolve(__dirname, './src/hooks'),
      '@types': path.resolve(__dirname, './src/types'),
    }
  },
  server: {
    port: 5173,
    proxy: {
      // Proxy REST calls and WebSocket upgrades to the API
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
        ws: true,
      },
    },
    allowedHosts: ['localhost', '127.0.0.1', 'sirensong.app', 'inartificial-fishier-ngoc.ngrok-free.dev'],
  },
  build: {
    outDir: 'dist',
  },
});
