diff --git a/java/dev/enola/web/UI.java b/java/dev/enola/web/UI.java index 8169905e..1db72f7c 100644 --- a/java/dev/enola/web/UI.java +++ b/java/dev/enola/web/UI.java @@ -97,7 +97,7 @@ public UI(EnolaServiceBlockingStub service, ThingMetadataProvider metadataProvid public void register(WebHandlers handlers) { // TODO Hard-coding this here like that is non-sense of course... will be fixed later! // BTW It's ./public/ instead of ./web/public/ only because web/README.md assumes `cd web`. - var fixMeToNotBeHardCoded = new File("./public/"); + var fixMeToNotBeHardCoded = new File("./web-out/"); handlers.register("/wui/", new StaticWebHandler("/wui/", fixMeToNotBeHardCoded)); handlers.register("/ui/static/", new StaticWebHandler("/ui/static/", "static")); handlers.register("/ui", this); diff --git a/web/ToDo.md b/web/ToDo.md index 6952544c..6702a911 100644 --- a/web/ToDo.md +++ b/web/ToDo.md @@ -20,9 +20,12 @@ ## Tech -1. Try https://bun.sh/docs/bundler/html 1. Apply https://bun.sh/docs/typescript#suggested-compileroptions 1. Fix `bun tsc` +1. Adopt https://bun.sh/docs/bundler/fullstack ... and fix CORS! +1. Either rename web-out/index*.html to `index.html` in `build.ts`, + OR make `../enola server` send either (better) `Cache-Control: no-cache` & `ETag: "abcdef1234"` + (or just `Cache-Control: no-store`; or `max-age=0`, really same?) ## Functional diff --git a/web/public/index.html b/web/public/index.html index bcaf750e..9a8740ef 100644 --- a/web/public/index.html +++ b/web/public/index.html @@ -33,6 +33,6 @@
- + diff --git a/web/src/bun/build.ts b/web/src/bun/build.ts index 08613084..12241834 100755 --- a/web/src/bun/build.ts +++ b/web/src/bun/build.ts @@ -2,25 +2,30 @@ import { build } from "bun" -// TODO Run both tsc & test from here, e.g. by using `concurrently` or `npm-run-all` (README.md) +// TODO Adopt https://bun.sh/docs/bundler/fullstack -// TODO Support watch mode, ideally like https://esbuild.github.io/api/#live-reload +// TODO Run both tsc & test from here, e.g. by using `concurrently` or `npm-run-all` (README.md) const result = await build({ - entrypoints: ["src/browser/index.ts"], - outdir: "public/bundles/", + html: true, + experimentalCss: true, + + entrypoints: ["public/index.html"], + outdir: "web-out/", minify: true, sourcemap: "linked", - // TODO naming: "./[dir]/[name]-[hash].[ext]" BUT then how to reference it in the HTML?! + naming: "./[dir]/[name]-[hash].[ext]", throw: true, }) -if (!result.success) { +if (result.success) { + // result.outputs.map(output => console.log("✅", output.path)) + console.log("✅ Successfully 📦 bundled!") + process.exit(0) +} else { console.error("Build failed:", result.logs) process.exit(1) } - -// TODO How to bundle CSS as well?