fix: respect custom base paths for built assets (#4879)

This commit is contained in:
Loi Nguyen
2026-07-30 21:10:53 +07:00
committed by GitHub
parent 48f04a0a7d
commit 5e0a4c43e6
2 changed files with 25 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { build } from "vite";
import { describe, expect, it } from "vitest";
describe("production build", () => {
it("emits font URLs relative to the generated stylesheet", async () => {
const result = await build({
configFile: "vite.config.ts",
logLevel: "silent",
build: { write: false },
});
const outputs = Array.isArray(result) ? result : [result];
const stylesheet = outputs
.flatMap((output) => ("output" in output ? output.output : []))
.find((item) => item.type === "asset" && item.fileName.endsWith(".css"));
expect(stylesheet).toBeDefined();
if (!stylesheet || stylesheet.type !== "asset") {
throw new Error("Production build did not emit a stylesheet");
}
const css = String(stylesheet.source);
expect(css).toMatch(/url\(\.\/jetbrains-mono/);
expect(css).not.toMatch(/url\(\/assets\/jetbrains-mono/);
}, 15_000);
});
+1
View File
@@ -13,6 +13,7 @@ import svgLoader from "vite-svg-loader";
import tailwindcss from "@tailwindcss/vite"; import tailwindcss from "@tailwindcss/vite";
export default defineConfig(() => ({ export default defineConfig(() => ({
base: "./",
define: { define: {
__CLOUD_URL__: JSON.stringify(process.env.CLOUD_URL || "https://cloud.dozzle.dev"), __CLOUD_URL__: JSON.stringify(process.env.CLOUD_URL || "https://cloud.dozzle.dev"),
}, },