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

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  const isDesktop = mode === 'desktop';

  return {
    plugins: [react()],
    base: isDesktop ? './' : '/',
    build: {
      outDir: isDesktop ? 'dist-desktop' : 'dist',
      emptyOutDir: true,
    },
    server: {
      proxy: {
        '/api': {
          target: isDesktop ? 'https://nav.smyhub.com' : 'http://127.0.0.1:8787',
          changeOrigin: true,
        },
      },
    },
  };
});
