nixpkgs/pkgs/by-name/mo/models-dev/post-build-rename-index-file.patch
Thierry Delafontaine faadfb7ab8
models-dev: add patch to rename hashed index file back to index.html
This change addresses an issue in Bun 1.2.13 (used in release 25.05)
where HTML entry points are generated with a hash appended to the
filename. As a result, the build fails unless the hashed index file is
renamed back to `index.html`.

The added patch scans the `./dist` directory for the hashed index
file and renames it back to `index.html` to ensure compatibility with
subsequent build steps.
2025-07-30 20:04:29 +02:00

19 lines
712 B
Diff

diff --git i/packages/web/script/build.ts w/packages/web/script/build.ts
index 9bdcdb3..e9ce1c9 100755
--- i/packages/web/script/build.ts
+++ w/packages/web/script/build.ts
@@ -14,6 +14,13 @@ for await (const file of new Bun.Glob("./public/*").scan()) {
await Bun.write(file.replace("./public/", "./dist/"), Bun.file(file));
}
+const distFiles = await fs.readdir("./dist");
+const htmlFile = distFiles.find(file => file.startsWith("index-") && file.endsWith(".html"));
+
+if (htmlFile) {
+ await fs.rename(`./dist/${htmlFile}`, "./dist/index.html");
+}
+
let html = await Bun.file("./dist/index.html").text();
html = html.replace("<!--static-->", Rendered);
await Bun.write("./dist/index.html", html);