CLI
@viewfly/cli scaffolds Viewfly projects on Vite + TypeScript. Optional features (e.g. scoped styles) and generated files depend on the CLI version you run.
Flags
--template <name>— template id (commonlyvite).--features <list>— comma-separated extras (e.g.router,scoped-css).--pm <pnpm|npm|yarn>— package manager.--install— install dependencies after create.
Usage
npm install -g @viewfly/cli
viewfly create my-appOr without a global install:
npx @viewfly/cli create my-appNon-interactive (scripts / CI):
npx @viewfly/cli create my-app \
--template vite \
--features router,scoped-css \
--pm pnpm \
--installcd into the project, install if needed, then start the dev server (often npm run dev).
Troubleshooting
- Command not found — with global install, ensure the global bin is on
PATH; otherwise usenpx @viewfly/cli create my-app. - Global install permission errors — avoid forced elevation; prefer
npx,pnpm dlx, oryarn dlx. - Dependencies missing — you skipped
--installor declined auto-install; runnpm install/pnpm install/yarnin the project.
Dev server and HMR
The Vite template registers viewflyHmrPlugin() from @viewfly/devtools in vite.config.ts: Viewfly function components get hot updates under vite dev (or your dev script). vite build does not load this plugin, so production output and behavior stay unchanged.
If you remove the plugin, development still works—you just lose official HMR. Options and caveats for manual setup are documented on npm for @viewfly/devtools. With the optional scoped-css feature, vite-scoped-css-plugin is added alongside HMR in the same config.
More
Full options and template layout: @viewfly/cli on npm.