feat: integrate platform backend and application interfaces
This commit is contained in:
+25
-6
@@ -2,32 +2,51 @@ import { readFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
|
||||
import { parseChangelog } from "./src/lib/release";
|
||||
|
||||
const webDir = dirname(fileURLToPath(import.meta.url));
|
||||
const localVersion = readFileSync(resolve(webDir, "../VERSION"), "utf8").trim() || "dev";
|
||||
const localChangelog = readFileSync(resolve(webDir, "../CHANGELOG.md"), "utf8");
|
||||
|
||||
const redirectAdminPath: Plugin = {
|
||||
name: "redirect-admin-path",
|
||||
configureServer(server) {
|
||||
server.middlewares.use((request, response, next) => {
|
||||
if (request.url === "/admin") {
|
||||
response.statusCode = 301;
|
||||
response.setHeader("Location", "/admin/");
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
next();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
base: process.env.VITE_BASE || "/",
|
||||
plugins: [react()],
|
||||
plugins: [redirectAdminPath, react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": resolve(webDir, "src"),
|
||||
"tdesign-react": resolve(webDir, "node_modules/tdesign-react"),
|
||||
},
|
||||
dedupe: ["react", "react-dom", "tdesign-react"],
|
||||
},
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(localVersion),
|
||||
__APP_RELEASES__: JSON.stringify(parseChangelog(localChangelog)),
|
||||
},
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: 3000,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: `http://127.0.0.1:${process.env.MIRAGENFLOW_SERVER_PORT || "3100"}`,
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
"/admin": {
|
||||
target: "http://127.0.0.1:3003",
|
||||
target: `http://127.0.0.1:${process.env.MIRAGENFLOW_ADMIN_PORT || "3003"}`,
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user