Add a game
Each game is a static page in games/<folder> of the chatbotgang/mini-games repository.
-
Create
games/<folder>withindex.html,src/main.ts, avite.config.tsthat setsbase: "./", and apackage.jsonwhoseminiGamefield names the game:"miniGame": {"id": "my-game","title": { "zh-TW": "…", "en": "…", "ja": "…", "th": "…" }} -
Connect to the host with
@mini-games/game-kit:import { connectHost } from "@mini-games/game-kit";const host = connectHost(); // applies theme and lang to <html>host.onConfig((config) => redraw(config));host.onPause((paused) => (paused ? stop() : start()));// After the first frame is drawn:host.ready(); -
Keep the game logic in pure functions with Vitest tests, and the canvas or DOM code apart.
-
Add the game’s JS to
.size-limit.jsonwith a 15 kB gzip limit. -
Add the game to the site’s
devDependenciesinapps/web/package.json, and add a page for it in each language underapps/web/src/content/docs/**/games/. -
Add a changeset for
@mini-games/webso the next release deploys it.
pnpm dev builds the games, copies them under /v1/ and starts the site.