import { defineConfig } from "vite";
import preact from "@preact/preset-vite";

const serverTarget = "http://localhost:8080";

export default defineConfig({
  base: "/app/",
  plugins: [preact()],
  build: {
    outDir: "dist",
    sourcemap: true,
  },
  server: {
    port: 5173,
    proxy: {
      "/api": {
        target: serverTarget,
        changeOrigin: true,
      },
      "/attachments": {
        target: serverTarget,
        changeOrigin: true,
      },
      "/docs": {
        target: serverTarget,
        changeOrigin: true,
      },
      "/health": {
        target: serverTarget,
        changeOrigin: true,
      },
      "/static": {
        target: serverTarget,
        changeOrigin: true,
      },
      "/sw.js": {
        target: serverTarget,
        changeOrigin: true,
      },
      "/ws": {
        target: "ws://localhost:8080",
        ws: true,
      },
      "^/app$": {
        target: serverTarget,
        changeOrigin: true,
      },
    },
  },
});
