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

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({
      // Vue plugin configuration
    }),
    react(),
  ],
  root: 'client',
  build: {
    outDir: '../dist/client',
    emptyOutDir: true,
  },
  server: {
    host: '0.0.0.0', // Allow external connections (needed for WSL2)
    port: 5173,
    strictPort: false,
    proxy: {
      '/api': {
        target: 'http://localhost:5000',
        changeOrigin: true,
      },
    },
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './client/src'),
      '@vue-components': path.resolve(__dirname, './client/src/vue'),
      '@react-components': path.resolve(__dirname, './client/src/react'),
    },
    dedupe: ['vue', 'react', 'react-dom'],
  },
  optimizeDeps: {
    include: ['vue', 'vue-router', 'react', 'react-dom', 'react-router-dom'],
  },
});
