Skip to content

Commit 67d0fac

Browse files
chore(ui): give flatten-output a clearer error when the HTML is missing
Addresses Copilot review feedback on #2501: if the singlefile-inlined HTML isn't where we expect it (e.g. because a future Vite/Rolldown change alters the output path), throw with the app name and expected path instead of letting renameSync surface a bare ENOENT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 61573d3 commit 67d0fac

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

ui/vite.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig, Plugin } from "vite";
22
import react from "@vitejs/plugin-react";
33
import { viteSingleFile } from "vite-plugin-singlefile";
4-
import { renameSync, rmSync } from "fs";
4+
import { existsSync, renameSync, rmSync } from "fs";
55
import { resolve } from "path";
66

77
const app = process.env.APP;
@@ -24,6 +24,11 @@ function flattenOutput(): Plugin {
2424
closeBundle() {
2525
const nested = resolve(outDir, `src/apps/${app}/index.html`);
2626
const flat = resolve(outDir, `${app}.html`);
27+
if (!existsSync(nested)) {
28+
throw new Error(
29+
`flatten-output: expected built HTML at ${nested} for app "${app}" but it was not emitted`,
30+
);
31+
}
2732
renameSync(nested, flat);
2833
rmSync(resolve(outDir, "src"), { recursive: true, force: true });
2934
},

0 commit comments

Comments
 (0)