Files
clawdbot/ui/vite.config.ts
Benjamin Jesuiter 7dcf19d902 fix(ui): default to relative paths for control UI assets
Changes the default base path from "/" to "./" so the control UI works
correctly when served under a custom basePath (e.g., /jbclawd/).

Previously, assets were referenced with absolute paths like /assets/...,
which failed when the UI was served under a subpath. With relative paths
(./assets/...), the browser resolves them relative to the HTML location,
making the UI work regardless of the configured basePath.
2026-01-09 15:32:55 +01:00

36 lines
911 B
TypeScript

import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
const here = path.dirname(fileURLToPath(import.meta.url));
function normalizeBase(input: string): string {
const trimmed = input.trim();
if (!trimmed) return "/";
if (trimmed === "./") return "./";
if (trimmed.endsWith("/")) return trimmed;
return `${trimmed}/`;
}
export default defineConfig(({ command }) => {
const envBase = process.env.CLAWDBOT_CONTROL_UI_BASE_PATH?.trim();
const base = envBase ? normalizeBase(envBase) : "./";
return {
base,
publicDir: path.resolve(here, "public"),
optimizeDeps: {
include: ["lit/directives/repeat.js"],
},
build: {
outDir: path.resolve(here, "../dist/control-ui"),
emptyOutDir: true,
sourcemap: true,
},
server: {
host: true,
port: 5173,
strictPort: true,
},
};
});