Skip to content

Assets CLI

The pidgn assets command manages your project’s JavaScript and CSS assets. It scaffolds a starter asset directory, bundles and fingerprints files with Bun, and provides a watch mode for development.

CommandDescription
pidgn assets setupGenerate starter asset files, package.json, and bunfig.toml.
pidgn assets setup --ssrSame as setup, plus SSR worker script and sample React component.
pidgn assets buildBundle, minify, fingerprint, and generate the asset manifest.
pidgn assets watchWatch source files and rebuild on change (Bun watch mode).
Terminal window
pidgn assets setup

Creates the following structure:

assets/
app.js # Starter JavaScript entry point
app.css # Starter CSS file
public/
assets/ # Output directory (created if missing)
package.json # Bun/npm dependencies
bunfig.toml # Bun build configuration

After setup, install dependencies:

Terminal window
bun install
Terminal window
pidgn assets setup --ssr

Creates the standard files above, plus:

assets/
ssr-worker.js # Bun worker script for server-side rendering
components/
App.jsx # Sample React component

The package.json includes react and react-dom as dependencies when using --ssr.

Terminal window
pidgn assets build

The build command performs these steps:

  1. Bundle JavaScript — runs bun build assets/app.js --outdir public/assets --minify to produce a minified bundle.

  2. Copy CSS — copies assets/app.css to public/assets/app.css.

  3. Fingerprint files — computes an FNV-1a hash of each output file and creates a fingerprinted copy (e.g. app-2b3e914a.js).

  4. Generate manifest — writes public/assets/assets-manifest.json mapping original filenames to fingerprinted filenames.

{
"app.js": "app-2b3e914a.js",
"app.css": "app-7f1dc3e8.css"
}

The asset middleware reads this manifest at runtime to resolve assetPath("app.js") to the fingerprinted URL.

Terminal window
pidgn assets watch

Starts Bun in watch mode. When any file under assets/ changes, the build runs again automatically. Use this alongside pidgn server during development:

Terminal window
# Terminal 1: application server with auto-restart
pidgn server
# Terminal 2: asset rebuilds on change
pidgn assets watch
  1. One-time setup

    Terminal window
    pidgn assets setup
    bun install
  2. During development — run both commands in separate terminals:

    Terminal window
    pidgn server # Rebuilds Zig on change
    pidgn assets watch # Rebuilds assets on change
  3. For production — build once before deploying:

    Terminal window
    pidgn assets build
    zig build -Doptimize=.ReleaseSafe