DEV Community

Tanvir Mahin
Tanvir Mahin

Posted on

Cmpgen | CLI to genarate React.js component

Compgen is a component boilerplate code genaration Command Line Interface (CLI). It will generate JS file, CSS/SCSS/SASS file with index.js file for your react component. You can install it globally with NPM. With the command:
npm install cmpgen -g

To use it. Go to the folder where you want to create the components, open the terminal, and type:

cmpgen FooterComponent -i -c sass

  • FooterComponent is the name of the component.
  • We want an index.js file in the component directory so -i flag is passed.
  • -c is for specifying the type of stylesheet. In this case, it is a sass file.

If you want to use Cmpgen with a project you can make a confg.cmpgen.json file in the root of your project and open the root folder in the terminal. There you can define the dir parameter for specifying the directory where the component will generate. Config file with all available options:
{
"dir":"./project/",
"index":true,
"css":"sass"
}

The official documentation link:https://devnops.tech/cmpgen/
Github: https://github.com/TanvirMahin24/cmpgen
NPM: https://www.npmjs.com/package/cmpgen

Top comments (0)