diff --git a/Dockerfile b/Dockerfile index 05f7001f..1facdff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN git clone --depth 1 https://github.com/ReaJason/MemShellParty.git . && \ # https://hub.docker.com/r/oven/bun FROM --platform=$BUILDPLATFORM oven/bun:1.3.11 AS frontend -ARG ROUTE_ROOT_PATH="/" +ARG ROUTE_ROOT_PATH="" ARG CONTEXT_PATH="" WORKDIR /usr/src/web @@ -56,4 +56,4 @@ ENV INTERNAL_JAVA_OPTS="\ EXPOSE 8080 -ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS $INTERNAL_JAVA_OPTS -jar app.jar $BOOT_OPTS"] \ No newline at end of file +ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS $INTERNAL_JAVA_OPTS -jar app.jar $BOOT_OPTS"] diff --git a/web/.env.production b/web/.env.production index 406c7e8c..2f3c8227 100644 --- a/web/.env.production +++ b/web/.env.production @@ -1,2 +1,2 @@ VITE_APP_API_URL= -VITE_APP_BASE_PATH=/ui \ No newline at end of file +VITE_APP_BASE_PATH=/ui diff --git a/web/vite.config.ts b/web/vite.config.ts index ef351cb3..b7a1afac 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -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", + } + : {}), + }, }, - }, + }; });