A powerful, interactive, universal CLI scaffolding tool for generating robust NPM component libraries and web applications using TypeScript and Vite.
Instead of maintaining separate boilerplate repositories for different frameworks, this CLI dynamically scaffolds a package tailored to your exact needs. With a simple interactive prompt, you can generate:
- Pure Vanilla TypeScript packages/apps
- Vue 3 Component Libraries/Apps
- React Component Libraries/Apps
- Svelte Component Libraries/Apps
- Solid Component Libraries/Apps
Furthermore, the CLI automatically detects your chosen framework and allows you to seamlessly integrate popular UI component libraries (like Element Plus, Ant Design, Material UI, Vant, etc.) out of the box!
- Interactive Prompts: Choose your project type (Library/Web App), JavaScript framework, matching UI library, CSS preprocessor (Sass/Less), and CSS framework (UnoCSS/TailwindCSS) on the fly.
- Vite Powered: Pre-configured Vite pipeline capable of emitting
ESM,CJS,UMD, andIIFEformats for libraries, as well asindex.d.tsdeclaration files usingvite-plugin-dts. - Auto Dependency Injection: The CLI dynamically injects the necessary Vite plugins (e.g.,
@vitejs/plugin-vue,@vitejs/plugin-react),peerDependencies, anddevDependenciesbased on your selections. - Zero Configuration TSX/JSX: Automatically writes the correct
tsconfig.jsonrules for React or Solid JSX preservation. - Built-in Visual Playground: Every scaffolded project automatically includes a miniature Vite server (
pnpm dev) for real-time visual UI development and testing. - Out-of-the-box Component Testing: Automatically configures Jest component tests tailored to your chosen framework (including test libraries and ESM resolution).
- Code Quality Built-in: All generated projects come fully equipped with Jest, ESLint, Prettier, Husky, Commitlint, and
release-itfor automated publishing.
You can instantly scaffold a new project without installing anything globally by using npx, pnpm dlx, or yarn dlx (or create commands):
npx create-vite-npm-ts-template my-component-library
# or
pnpm create vite-npm-ts-template@latest my-component-library
# or
yarn create vite-npm-ts-template@latest my-component-libraryYou can bypass the interactive prompts entirely by passing the arguments directly via CLI flags:
npx create-vite-npm-ts-template --name=my-app --type=library --js=vue --ui=element-plusAvailable flags:
--name: The project name.--type: The project type (library,web).--js: The JS framework (none,vue,react,svelte,solid).--ui: The UI framework (none,element-plus,antd,@mui/material,vant, etc.).--css: The CSS preprocessor (none,sass,less).--css-fw: The CSS framework (none,unocss,tailwind).
- Project name: (e.g.,
my-component-library) - Project Type: (Library, Web Application)
- JS Framework: (Vanilla TS, Vue 3, React, Svelte, Solid)
- UI Framework: (Filtered intelligently based on your JS framework choice)
- CSS Preprocessor: (None, Sass/SCSS, Less)
- CSS Framework: (None, UnoCSS, TailwindCSS)
- Git Initialization: (Automatically run
git init)
Once scaffolding is complete, simply navigate into your new project, install dependencies, and start building:
cd my-component-library
pnpm install
pnpm dev # Start visual playground
pnpm build # Build for productionThe CLI currently supports automatic integration for the following UI libraries:
- Vue 3: Element Plus, Ant Design Vue, Vant
- React: Ant Design, Material UI (@mui/material)
- Svelte: Sveltestrap
- Solid: SUID (@suid/material)
(You can also choose "None" for any framework to get a pure, unstyled boilerplate).
- Clone the repository.
- Install dependencies via
pnpm install. - Modify the core logic in
bin/index.jsor the base boilerplate insidetemplate/. - We use Husky and Commitlint to enforce Conventional Commits for the CLI's source code.
- When ready to publish a new version of this CLI to NPM, you must log in to the official registry (if using a mirror like CNPM) and run
pnpm release:(npm login --registry=https://registry.npmjs.org/ pnpm release
release-itwill automatically bump the version, generate a git tag, and publish).
We provide automated test scripts to verify the scaffolding process without manual input. These scripts inject predefined prompt responses:
node test-cli.js- Tests scaffolding a React + Ant Design project.node test-cli-vue.js- Tests scaffolding a Vue + Element Plus project.node test-cli-solid.js- Tests scaffolding a Solid + SUID project.
This project enforces the Conventional Commits specification using commitlint.
When you commit your changes, you must format your commit messages with specific prefixes. For example:
feat: add a new featurefix: resolve a bugchore: update dependenciesdocs: update readme
If you don't follow this format, your commit will be rejected by the Git commit-msg hook.