๐ vite-plugin-create just got a fresh update โ v1.1.1 is live!
๐งฉ You can now:
โ Generate standalone files (perfect for hooks, utils, etc.)
โ Assign a custom basePath for each generator
Itโs a small but powerful step toward more flexible scaffolding.
๐ See whatโs new: https://github.com/dimatitov/vite-plugin-create/releases/tag/1.1.1
Feedback and ideas are always welcome โ letโs make Vite development faster together ๐ช
๐ข Update โ v1.0.1 is out now!
The new version includes: custom generators, JS/TS template support, per-generator naming styles, and more. ๐ Check out the new features and see examples
Iโve only recently started sharing articles and documentation publicly.
Previously, all my writing was internal โ release notes, docs, research, roadmaps โ all within teams.
But after publishing my first Vite plugin, I felt the need to share it with the world. To get feedback. To see if anyone would find it useful. Maybe someone would suggest a feature, spot a bug โ or just say โthanks.โ
And while writing about it, I realized something: I enjoy this. I was already thinking about the next topic. But letโs get back to the plugin.
How It All Started: Inspired by NestJS
Iโve been a developer for over 5 years โ mostly frontend, but Iโve been getting into backend recently too.
It started with Node.js + Express, and then, at work, we launched a project to automate voice calls and analyze transcripts using OpenAI. I chose to build it with NestJS. I was only mildly familiar with it, but had to dive deep.
And then, I ran:
nest g resource
โฆand boom โ a full module appeared.
I literally said out loud:
โWhy doesnโt React have something like this?!โ
Yes, there are snippets. Yes, some third-party generators exist. But I wanted structure.
I wanted to type a command โ and get a scaffolded component. Just like Nest.
The Frontend Pain
Back to a new internal project: a Telegram Web App using Vite + TypeScript + React + Zustand. A simple, small app.
I start coding, and suddenly Iโm back at it again:
- Create a folder
- Create Component.tsx
- Add index.ts
- Add props interface
- Import styles
- โฆand repeat
Eventually, a new page design landed โ and I had to do it all over again.
My eye started twitching.
So I wrote a bash script. It scaffolded everything I needed. Made it executable. Called it create-component.
And you know what? I was so happy.
Then came create-store, create-page, and so on. Life got easier.
But there were still problems:
- Every project has slightly different templates
- Folder structure varies
- Sometimes you need something custom โ and have to rewrite the script
Especially on legacy projects โ one had Angular 1.5 and React mixed in ๐ตโ๐ซ
Donโt ask.
Vite Deserves nest g
One day I thought:
โI love Vite. Why not build something like nest g resource โ customizable and extensible โ for it?โ
And so vite-plugin-create was born.
A plugin + CLI to quickly generate components, pages, stores, whatever โ from your own templates.
Naming? Customizable. Templates? Yours. Command? One.
Building It: Not As Easy As I Thought
I first warmed up with a simple plugin: vite-plugin-import-alias.
It was smaller in scope, helped me get used to publishing, npm, docs, and user feedback.
But I already knew what the next one would be: vite-plugin-create.
The idea looked simple at first. I had my bash scripts. Why not repeat the same logic, just cleaner?
I imagined:
- Templates for files
- A config to define structure, names, and naming styles
- Catch a CLI command like vite create:component Button โ and scaffold away
But then came the disappointment
Turns out, Vite has no API to add custom CLI commands.
So vite create:component? Not possible. I really wanted it to feel native, like nest g, but no luck.
The solution: a custom CLI
I added bin/cli.ts, defined commands, and in package.json:
"bin": {
"vite-create": "./dist/bin/cli.js"
}
Now, everything runs via:
npx vite-create component Button
Not exactly part of Viteโs CLI, but clean, stable, and simple.
Config & Naming
Next step: how should names be formatted?
Components should be PascalCase โ but stores or utils? Maybe camelCase or kebab-case.
So I added a fileNameStyle option in the config:
- pascalCase
- camelCase
- kebabCase
- original (leave as typed)
Default is PascalCase, but I plan to let each generator (component, store, etc.) have its own style.
The Config & Templates
One of my goals: make it dead simple and easy to customize.
You shouldnโt need to guess:
โWhere do templates go?โ
โWhat format should config be?โ
Just run:
npx vite-create init
It creates:
templates/ with a base component
vite-create.config.json with a working example
{
"defaultPath": "src",
"fileNameStyle": "pascalCase",
"generators": {
"component": {
"path": "components/{{name}}",
"files": {
"{{name}}.tsx": "templates/component/component.tsx",
"index.ts": "templates/component/index.ts",
"{{name}}.module.scss": "templates/component/style.scss"
}
}
}
}
Templates are just .tsx, .ts, .scss files with Handlebars variables like {{name}}, {{PascalCaseName}}, etc.
import styles from './{{name}}.module.scss';
export interface Props {
className?: string;
}
export const {{name}}: React.FC<Props> = ({ className }) => {
return <div className={styles.root}>{{name}} component</div>;
};
What vite-plugin-create Can Do (Right Now)
โ Scaffold any component (or entity) from your templates
โ Supports .tsx, .scss, .test.tsx, or whatever you want
โ Works with any naming convention
โ
Lets you define custom generators, like:
npx vite-create store userStore
Or anything you define in the config.
๐ฃ Roadmap
Hereโs what Iโm planning next:
- โ Full support for custom generators
- ๐ Choose default format: .tsx or .jsx (maybe via โ jsx flag)
- ๐ Template groups โ e.g. pages/, widgets/, shared/
- โ๏ธ Per-generator naming style (e.g. PascalCase for components, camelCase for hooks)
- ๐งฐ Possibly: a minimal GUI to edit your config visually โ in browser or CLI
If youโre tired of boilerplate and repetitive component creation โ give vite-plugin-create a try.
Feedback, ideas, PRs โ all welcome.
MIT licensed. Open source. Built with โค๏ธ
Top comments (0)