Skip to content

Trim the web build and serve it the way a host would - #1

Merged
sschroederdev merged 2 commits into
mainfrom
build/trim-web-bundle
Oct 1, 2026
Merged

sschroederdev merged 2 commits into
mainfrom
build/trim-web-bundle

Conversation

@sschroederdev

Copy link
Copy Markdown
Owner

No description provided.

sschroederdev and others added 2 commits September 7, 2026 21:27
Everything here is small next to the ~10MB CPython runtime the page
pulls from the pygbag CDN, but it removes files nothing reads and the
debug chrome that does not belong in an embed on a portfolio page.
Output goes from 77KB to 34KB.

- Drop the .apk. pygbag emits both an .apk and a .tar.gz holding the
  same files, and the loader only reads the .apk when the page is
  hosted on itch.io. Every other host takes the .tar.gz.
- Drop pygbag's favicon and its link tag, which mean nothing inside an
  iframe, and the browserfs.min.js script tag, which pygbag emits with
  a doubled slash so the CDN 404s it on every load.
- Turn off the xterm.js debug console and the audio shim via data-os.
  The console is ~90KB over the wire and this game has no sound. Python
  output still reaches the browser console.
- Make the page transparent behind the canvas. pygbag paints it flat
  grey, once in CSS and again from JS after boot, which would sit as a
  grey box inside a themed page.

Also stop passing --serve through to pygbag. Its test server rewrites
the CDN URLs to proxy through itself, so what you were testing was not
what a real host serves. The build now always produces the trimmed
output and --serve hands it to a plain static server afterwards.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Lint, tests and the web build run on every pull request. On a push to
main the built bundle goes to the portfolio site as a pull request, so
each build is reviewed on its Vercel preview before it ships.

The demo on the site is an iframe served from the site's own public/
folder so that it is same-origin, so the built files have to live in
that repo. GITHUB_TOKEN cannot reach another repository, so publishing
uses a fine-grained PAT and a machine-owned branch that is rebuilt and
force-pushed each run, keeping one pull request open instead of a pile.

The tests drive the state machine a frame at a time rather than running
Game.run, which loops until the window closes, and run headless under
SDL's dummy driver. They lean towards the bugs the README calls out,
including the two pygbag traps that only surface in a browser.

build_web.py grows a --strict flag. A pygbag upgrade can change the
markup the trims rewrite; without it the build would still succeed and
ship an embed with a grey box around it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sschroederdev
sschroederdev merged commit 5f18da5 into main Oct 1, 2026
2 checks passed
@sschroederdev
sschroederdev deleted the build/trim-web-bundle branch October 1, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant