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.
Commands
Section titled “Commands”| Command | Description |
|---|---|
pidgn assets setup | Generate starter asset files, package.json, and bunfig.toml. |
pidgn assets setup --ssr | Same as setup, plus SSR worker script and sample React component. |
pidgn assets build | Bundle, minify, fingerprint, and generate the asset manifest. |
pidgn assets watch | Watch source files and rebuild on change (Bun watch mode). |
pidgn assets setupCreates the following structure:
assets/ app.js # Starter JavaScript entry point app.css # Starter CSS filepublic/ assets/ # Output directory (created if missing)package.json # Bun/npm dependenciesbunfig.toml # Bun build configurationAfter setup, install dependencies:
bun installSSR setup
Section titled “SSR setup”pidgn assets setup --ssrCreates the standard files above, plus:
assets/ ssr-worker.js # Bun worker script for server-side rendering components/ App.jsx # Sample React componentThe package.json includes react and react-dom as dependencies when using --ssr.
pidgn assets buildThe build command performs these steps:
-
Bundle JavaScript — runs
bun build assets/app.js --outdir public/assets --minifyto produce a minified bundle. -
Copy CSS — copies
assets/app.csstopublic/assets/app.css. -
Fingerprint files — computes an FNV-1a hash of each output file and creates a fingerprinted copy (e.g.
app-2b3e914a.js). -
Generate manifest — writes
public/assets/assets-manifest.jsonmapping original filenames to fingerprinted filenames.
Manifest format
Section titled “Manifest format”{ "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.
pidgn assets watchStarts Bun in watch mode. When any file under assets/ changes, the build runs again automatically. Use this alongside pidgn server during development:
# Terminal 1: application server with auto-restartpidgn server
# Terminal 2: asset rebuilds on changepidgn assets watchTypical workflow
Section titled “Typical workflow”-
One-time setup
Terminal window pidgn assets setupbun install -
During development — run both commands in separate terminals:
Terminal window pidgn server # Rebuilds Zig on changepidgn assets watch # Rebuilds assets on change -
For production — build once before deploying:
Terminal window pidgn assets buildzig build -Doptimize=.ReleaseSafe
Next steps
Section titled “Next steps”- Asset Pipeline — how the middleware loads the manifest and resolves paths
- Live Reload — automatic browser refresh on file changes
- Server-Side Rendering — use
setup --ssrto add React SSR - Dev Server — automatic application rebuilds during development
- CLI Overview — full list of pidgn CLI commands