95 lines
2.2 KiB
JavaScript
95 lines
2.2 KiB
JavaScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
function redirectSubsystemEntry(req, res, next) {
|
|
const rawUrl = req.url || "";
|
|
const [pathname, query = ""] = rawUrl.split("?");
|
|
|
|
if (pathname === "/databi" || pathname === "/money") {
|
|
res.statusCode = 301;
|
|
res.setHeader("Location", `${pathname}/${query ? `?${query}` : ""}`);
|
|
res.end();
|
|
return;
|
|
}
|
|
|
|
next();
|
|
}
|
|
|
|
function subsystemEntryPlugin() {
|
|
return {
|
|
name: "hyapp-subsystem-entry",
|
|
configureServer(server) {
|
|
server.middlewares.use(redirectSubsystemEntry);
|
|
},
|
|
configurePreviewServer(server) {
|
|
server.middlewares.use(redirectSubsystemEntry);
|
|
}
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
admin: new URL("./index.html", import.meta.url).pathname,
|
|
databi: new URL("./databi/index.html", import.meta.url).pathname,
|
|
money: new URL("./money/index.html", import.meta.url).pathname
|
|
}
|
|
}
|
|
},
|
|
css: {
|
|
modules: {
|
|
generateScopedName: "hy-[name]__[local]__[hash:base64:5]",
|
|
localsConvention: "camelCaseOnly"
|
|
}
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@": new URL("./src", import.meta.url).pathname
|
|
},
|
|
dedupe: ["react", "react-dom", "@emotion/react", "@emotion/styled"]
|
|
},
|
|
optimizeDeps: {
|
|
include: [
|
|
"@emotion/react",
|
|
"@emotion/styled",
|
|
"@mui/material/MenuItem",
|
|
"@mui/material/Select",
|
|
"@mui/material/TextField",
|
|
"@mui/material/styles",
|
|
"react",
|
|
"react-dom",
|
|
"react-dom/client",
|
|
"react/jsx-dev-runtime",
|
|
"react/jsx-runtime"
|
|
]
|
|
},
|
|
plugins: [subsystemEntryPlugin(), react()],
|
|
server: {
|
|
port: 7001,
|
|
proxy: {
|
|
"/api": {
|
|
target: "http://localhost:13100",
|
|
changeOrigin: true
|
|
},
|
|
"/__api_test__": {
|
|
target: "https://api-test.global-interaction.com",
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/__api_test__/, "")
|
|
},
|
|
"/__api_local__": {
|
|
target: "http://127.0.0.1:13000",
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/__api_local__/, "")
|
|
}
|
|
}
|
|
},
|
|
preview: {
|
|
port: 7001
|
|
},
|
|
test: {
|
|
environment: "jsdom",
|
|
setupFiles: "./src/test/setup.js"
|
|
}
|
|
});
|