build: assets link error

This commit is contained in:
ReaJason
2026-06-28 21:22:31 +08:00
parent 862ad44a0a
commit 7c0ae4b228
3 changed files with 23 additions and 19 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
VITE_APP_API_URL=
VITE_APP_BASE_PATH=/ui
VITE_APP_BASE_PATH=/ui
+20 -16
View File
@@ -2,25 +2,29 @@ import { reactRouter } from "@react-router/dev/vite";
import tailwindcss from "@tailwindcss/vite";
import mdx from "fumadocs-mdx/vite";
import path from "node:path";
import { env } from "node:process";
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";
import devtoolsJson from "vite-plugin-devtools-json";
import * as MdxConfig from "./source.config";
const isDev = env.NODE_ENV === "development";
export default defineConfig({
base: isDev ? "/" : `${env.VITE_APP_API_URL}/`,
plugins: [mdx(MdxConfig), tailwindcss(), reactRouter(), devtoolsJson()],
resolve: {
tsconfigPaths: true,
alias: {
"@": path.resolve(__dirname, "./app"),
...(!isDev
? {
"react-dom/server": "react-dom/server.node",
}
: {}),
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), "VITE_APP_");
const isDev = command === "serve";
const contextPath = env.VITE_APP_API_URL?.trim() ?? "";
return {
base: isDev || !contextPath ? "/" : `${contextPath}/`,
plugins: [mdx(MdxConfig), tailwindcss(), reactRouter(), devtoolsJson()],
resolve: {
tsconfigPaths: true,
alias: {
"@": path.resolve(__dirname, "./app"),
...(!isDev
? {
"react-dom/server": "react-dom/server.node",
}
: {}),
},
},
},
};
});