metronome/build.sh
Me Here 632890c812 Add build step (inline assets at build); drop "mockup" from the main app
The source index.html now keeps small @BUILD:* markers instead of the
~250KB of base64 blobs (audio samples, logos, favicon), which move to
assets/. build.sh inlines them into a self-contained dist/index.html
(+ dist/player.html); deploy.sh runs the build first and serves dist/.
dist/ is git-ignored. Keeps the single-file deploy while stopping the
samples from eating the editing budget.

Also reframe the main page as the full web app (it is not a mockup —
only the play-only player.html device is): drop "Mockup" from the title,
the source comment, and the README intro; add Build/Files docs and
correct the "no build step" claim.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 15:21:28 -05:00

24 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Assemble the deployed single-file pages from source + assets/.
#
# The source index.html keeps small @BUILD:* markers instead of the large base64
# blobs (audio samples, brand logos, favicon). This inlines those assets so the
# built page in dist/ is one self-contained file (zero deps, works fully offline).
# deploy.sh runs this first. dist/ is generated — don't edit or commit it.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
mkdir -p dist
python3 - <<'PY'
import json, os, pathlib
A = pathlib.Path("assets")
src = pathlib.Path("index.html").read_text()
src = src.replace("@BUILD:favicon@", (A / "favicon.b64").read_text().strip())
src = src.replace("@BUILD:logo-dark@", (A / "logo-dark.b64").read_text().strip())
src = src.replace("@BUILD:logo-light@", (A / "logo-light.b64").read_text().strip())
src = src.replace("/*@BUILD:samples@*/{}", json.dumps(json.load(open(A / "samples.json"))))
assert "@BUILD:" not in src, "unresolved build marker(s) remain in index.html"
pathlib.Path("dist/index.html").write_text(src)
pathlib.Path("dist/player.html").write_text(pathlib.Path("player.html").read_text()) # no assets to inline
print("built dist/index.html (%dKB) + dist/player.html (%dKB)" %
(os.path.getsize("dist/index.html") // 1024, os.path.getsize("dist/player.html") // 1024))
PY