import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import path from "path" // https://vitejs.dev/config/ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') return { plugins: [react()], // Explicitly configure public directory behavior if needed, // but usually 'public' is default. publicDir: 'public', optimizeDeps: { exclude: ['dagre'], // 'web-worker' needs to be optimized or handled correctly by Vite for elkjs include: ['elkjs/lib/elk.bundled.js', 'buffer'] }, resolve: { alias: { "@": path.resolve(__dirname, "./src"), // Force buffer to resolve to the installed package, not node built-in buffer: "buffer", }, }, server: { // Ensure static files are served correctly fs: { strict: false, }, proxy: { '/api': { target: env.VITE_API_TARGET || 'http://localhost:4000', changeOrigin: true, }, '/health': { target: env.VITE_API_TARGET || 'http://localhost:4000', changeOrigin: true, }, '/tasks': { target: env.VITE_API_TARGET || 'http://localhost:4000', changeOrigin: true, }, }, }, } })