From 3ccff98ffcee7e1248a49b5601cbb6031d77e70c Mon Sep 17 00:00:00 2001 From: McDope Date: Thu, 27 Aug 2026 01:58:45 +0200 Subject: [PATCH] feat(build): add a standalone mode for deploys with no backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `npx vite build --mode standalone` produces a build with multiplayer switched off, for any deploy served as plain static files that cannot reach the signaling server. The gate already existed — `main.ts`'s `MULTIPLAYER_SERVER_CONFIGURED = Boolean(import.meta.env.VITE_MULTIPLAYER_SERVER_URL)`, with `updateMultiplayerTabEnabled` hiding the tab when it is unset. What was missing was a way to ask for it: a default `vite build` runs in production mode and loads `.env.production.local`, so the URL is always present and the tab always appears. On a host the signaling server does not accept, that advertises a mode which cannot connect — found by uploading to itch.io and clicking it. **Named for what it is, not where it was first needed.** Nothing here is itch-specific: it applies to any subpath host, any fork without a server of its own, any static mirror. An earlier draft called the mode `itch` and that was simply the wrong noun. `.env.standalone` sets the variable to empty explicitly rather than letting the mode work by having no env file at all, so the intent is greppable in one place. **It is documentation, not a guarantee, and this was measured rather than assumed.** Vite's precedence is `.env` < `.env.local` < `.env.[mode]` < `.env.[mode].local`. Dropping a `.env.standalone.local` in place brings the Multiplayer tab straight back — verified, and it does so identically whether the tracked file exists or not. So the explicit file buys discoverability, not safety; the only check that holds is on the built artifact. Verified in both directions, since the risk here is symmetric: - `--mode standalone` → tabs are Local / Repo / Demos / gear, no Multiplayer - default `vite build` → Multiplayer still present, so the real deploy is untouched by this file existing Co-Authored-By: Claude Opus 5 (1M context) --- .env.standalone | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .env.standalone diff --git a/.env.standalone b/.env.standalone new file mode 100644 index 0000000..a44a4a9 --- /dev/null +++ b/.env.standalone @@ -0,0 +1,14 @@ +# Standalone build: no backend services configured. +# +# Used for any deploy where this app is served as plain static files and cannot +# reach our signaling server — an itch.io upload, a subpath host, a fork without +# a server of its own. Build with: +# +# npx vite build --mode standalone --base=./ +# +# Multiplayer is gated on this being falsy (`main.ts`'s +# MULTIPLAYER_SERVER_CONFIGURED); `updateMultiplayerTabEnabled` then hides the +# tab entirely, so the build never advertises a mode it cannot connect. +# +# This file states intent in one greppable place. It is not a guarantee — Vite's precedence means a .env.standalone.local silently overrides it (measured: the Multiplayer tab came back). Only checking the built artifact holds. +VITE_MULTIPLAYER_SERVER_URL=