sveltegen
v1.5.2
Published
A simple component generator CLI for Svelte/SvelteKit.
Maintainers
Readme
sveltegen
A simple, easy to use CLI for creating Svelte/SvelteKit components, actions, and routes, quickly and conveniently.
Now with 0 dependencies!
*Find me on NPM!*
Features
- Simple and easy generation of:
- Components
- Routes/Endpoints
- Actions
- Sveltegen handles file structure for you
Installation
Note: only run Sveltegen at your project root directory.
Install globally (recommended):
npm install -g sveltegen...or use npx to skip the install
npx sveltegenCommands
| command | description |
| -------------------------- | ---------------------------------------------------- |
| config | allows you to change the path to your output folders |
| help | shows all available commands |
| actionalias: a | makes a new action |
| componentalias: c | makes a new component |
| route alias: r | makes a new route |
Command Options
Below is a table of what commands have what options.
| | TypeScript | SCSS | Endpoint | Page |
| ----------- | ------------------ | ------------------ | ------------------ | ------------------ |
| action | :white_check_mark: | :x: | :x: | :x: |
| component | :white_check_mark: | :white_check_mark: | :x: | :x: |
| route | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Don't want to use TypeScript / SCSS? Don't worry, just don't put any -t -s flags! Sveltegen will create .css and .js files, as well as properly format your .svelte files, if you opt-out of either of them.
Usage
sveltegen <command> [options]For example, to create a new component named Button with SCSS and Typescript:
sveltegen component Button -t -s
// you can use the shorthand format too!
sveltegen c Button -t -sFile Output
Components:
[name].svelte
index.ts // or index.js if not using Typescript
index.scss // or index.css if not using SCSSRoutes:
[name]/index.svelte // optional
[name]/index.json.ts // optional ; or index.json.js if not using TypescriptActions:
[name].ts // or [name].js if not using Typescript