Skip to content

Build System

The Maho Storefront uses two build tools: UnoCSS for CSS generation and esbuild for JavaScript bundling. Both run as npm scripts and output to the public/ directory.

Build Pipeline

Scripts

CommandDescription
bun run buildBuild CSS + JS (runs both below)
bun run build:cssGenerate CSS with UnoCSS
bun run build:jsBundle JS with esbuild
bun run manifestGenerate component manifest
bun run devStart local Wrangler dev server
bun run deployDeploy to Cloudflare Workers

Output Files

FileSize (typical)SourceCache
public/styles.css~80-120KBUnoCSS1 year (hash-versioned)
public/controllers.js.txt~40-60KBesbuild1 year (hash-versioned)

Both files are imported as text modules by the Worker (via wrangler.toml text rules) and served with immutable cache headers. The .js.txt extension prevents Cloudflare from treating the file as executable JavaScript during upload.

Asset Versioning

The ASSET_HASH (in src/asset-version.ts) is a hash of the CSS + JS + page config contents. When any of these change, the hash changes, which:

  1. Updates the <link> and <script> URLs in rendered HTML
  2. Invalidates the edge cache version tag
  3. Forces browsers to fetch the new assets

This means zero-downtime deployments — old cached pages reference old asset URLs (still served from the 1-year cache), while new pages reference new URLs.

Next Steps