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

// Base is relative so the built files work whether you deploy them to
// your domain root or to a subfolder like /medicus/ on cPanel.
export default defineConfig({
  plugins: [vue()],
  base: './',
  server: {
    proxy: {
      // During local development (npm run dev), forward /api calls to
      // your local PHP server so you don't hit CORS issues.
      // Run PHP locally with: php -S localhost:8000 -t api
      '/api': {
        target: 'http://localhost:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
  build: {
    outDir: 'dist',
    emptyOutDir: true,
  },
});
