import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import tailwindcss from "@tailwindcss/vite";

// 老师端独立 SPA:构建产物由 hub 后端静态托管于 /app;
// 开发时 vite dev(:5173)把 API/认证请求代理到后端(:8788)。
const backend = "http://127.0.0.1:8788";

export default defineConfig({
  plugins: [svelte(), tailwindcss()],
  base: "/app/",
  build: {
    outDir: "dist",
    emptyOutDir: true,
  },
  server: {
    port: 5173,
    proxy: {
      "/database/api": backend,
      "/auth": backend,
      "/app/dev-login": backend,
      "/app/dev-login-teacher": backend,
    },
  },
});
