forked from EduCraft/curriculum-project-hub
build(filelib-web): 从 Svelte+Vite 改为 SvelteKit(adapter-static)
纯 SPA:adapter-static + fallback index.html,不做 SSR/预渲染。
index.html / main.ts / App.svelte 由 app.html + src/routes/ 取代。
两项配置是承重的(ADR-0029),不是风格选择:
appDir: '_filelib' 默认 _app 会与 admin-web 在根上注册的 /_app/*
撞成 Fastify 重复路由,启动即抛错。
paths.relative: false 同一份 index.html 会在 /app 和
/database/dashboard/users 等不同深度送出,
相对资源路径会解析到错的 base。
dev 代理表列出后端拥有的全部路径:JSON API、免鉴权 bootstrap
(/database/config)、OAuth、以及 DEV 一键登录端点 —— 后者不代理会被
SPA 回退吃掉。
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||
import { sveltekit } from "@sveltejs/kit/vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// 老师端独立 SPA:构建产物由 hub 后端静态托管于 /app;
|
||||
// 开发时 vite dev(:5173)把 API/认证请求代理到后端(:8788)。
|
||||
// 老师端 /app + 管理后台 /database/* 的唯一前端工程;构建产物由 hub 后端静态托管。
|
||||
// 开发时 vite dev(:5173)把 API/认证/一键登录请求代理到后端(:8788);
|
||||
// 页面路由全部由 SvelteKit 客户端路由处理,后端不参与。
|
||||
const backend = "http://127.0.0.1:8788";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [svelte(), tailwindcss()],
|
||||
base: "/app/",
|
||||
build: {
|
||||
outDir: "dist",
|
||||
emptyOutDir: true,
|
||||
},
|
||||
plugins: [tailwindcss(), sveltekit()],
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
"/database/api": backend,
|
||||
// 免鉴权 bootstrap(org slug + dev 开关);登录页和用户管理页都靠它。
|
||||
"/database/config": backend,
|
||||
"/auth": backend,
|
||||
// 后端拥有的 DEV 一键登录端点(签 cookie 后 302);不代理会被 SPA 回退吃掉。
|
||||
"/database/dev-login": backend,
|
||||
"/app/dev-login": backend,
|
||||
"/app/dev-login-teacher": backend,
|
||||
// 平台层 org 成员 API(用户管理面板)。
|
||||
"/api/org": backend,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user