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

const buildBasePath = process.env.PUBLIC_URL || process.env.VITE_BASE_PATH || '/';
const basePath = buildBasePath.endsWith('/') ? buildBasePath : `${buildBasePath}/`;

export default defineConfig({
  base: basePath,
  plugins: [react()],
  esbuild: {
    loader: 'jsx',
    include: /src\/.*\.jsx?$/,
    exclude: [],
  },
  optimizeDeps: {
    esbuildOptions: {
      loader: {
        '.js': 'jsx',
      },
    },
  },
  server: {
    port: 3000,
  },
  build: {
    outDir: 'build',
    emptyOutDir: true,
    sourcemap: false,
  }
})
