@masatomakino/demo-showcase
v0.1.2
Published
Generate demo HTML pages from JS/TS source files using Vite
Downloads
117
Maintainers
Readme
@masatomakino/demo-showcase
A CLI tool that generates demo HTML pages from JavaScript/TypeScript source files using Vite.
Place demo source files (e.g. demo_*.ts) in a directory, and this tool generates a browsable demo site with sidebar navigation — both as a dev server with HMR and as a static build.
Install
npm install --save-dev @masatomakino/demo-showcaseRequires Node.js >= 22.
Usage
Dev server (live preview with HMR)
npx demo-showcase dev --srcDir ./demoSrcStatic build
npx demo-showcase build --srcDir ./demoSrcOutput goes to ./docs/demo/ by default.
Options
| Option | Default | Description |
|--------|---------|-------------|
| --prefix <string> | "demo" | Filename prefix for demo pages |
| --srcDir <path> | "./demoSrc" | Demo source directory |
| --distDir <path> | "./docs/demo" | Output directory (build only) |
| --body <string> | "" | HTML body content |
| --style <string> | "" | Custom CSS styles |
| --port <number> | 3456 | Dev server port (dev only) |
| --open | false | Open browser on start (dev only) |
| --host <string> | "localhost" | Dev server host (dev only) |
How it works
- Scans
srcDirfor files matching{prefix}_*.tsor{prefix}_*.js - Generates an HTML entry point for each demo file
- Builds with Vite (static) or serves via Vite dev server (dev mode)
- Produces an index page with sidebar navigation linking all demos
Assets referenced via import in demo files are bundled by Vite automatically.
