import { defineConfig, normalizePath } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default defineConfig({
  envDir: '../../',
  plugins: [
    react(), 
    tailwindcss(),
    viteStaticCopy({
      targets: [
        {
          src: normalizePath(path.resolve(__dirname, '../shared/sounds')),
          dest: './'
        }
      ]
    })
  ],
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:5059',
        changeOrigin: true,
      },
      '/uploads': {
        target: 'http://localhost:5059',
        changeOrigin: true,
      },
      '/hubs': {
        target: 'http://localhost:5059',
        ws: true,
        changeOrigin: true,
      },
    },
  },
});
