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

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@fn_library": path.resolve(__dirname, "../../../frontend/functions"),
    },
  },
  server: {
    port: 5180,
    proxy: {
      "/api": {
        target: process.env.VITE_API_TARGET || "http://127.0.0.1:8095",
        ws: true,
        changeOrigin: true,
      },
      "/mcp": {
        target: process.env.VITE_API_TARGET || "http://127.0.0.1:8095",
        changeOrigin: true,
      },
    },
  },
  build: {
    outDir: "../backend/dist",
    emptyOutDir: true,
  },
});
