@ryands17/rcomp

A CLI tool for generating React Components

Usage no npm install needed!

<script type="module">
  import ryands17Rcomp from 'https://cdn.skypack.dev/@ryands17/rcomp';
</script>

README

rcomp CLI

A CLI for generating React Components.

Commands

  • rcomp create component or rcomp c component will generate a component in the components folder of src by default
  • rcomp create page or rcomp c page will generate a page / route in the pages folder of src by default

Currently this plugin supports 2 options:

  1. Creating a function or class Component
  2. Creating a scss or styled-component file

Configuration options

  • You can specify the following configuration in your package.json. Default values for all are shown below
"rcomp": {
  "componentsDirectory": "components",
  "pagesDirectory": "pages",
  "createStories": false,
  "outputExtension": "js"
}
  • componentsDirectory: The custom folder for components
  • pagesDirectory: The custom folder for pages
  • createStories: If you want to generate stories for your component (if using Storybook)
  • outputExtension: The generated extension for your project (.js or .ts)

Note: The base directory will be src though.

License

MIT - see LICENSE

Enhancements

  • Write robust tests!
  • Read components and pages folder from project config (currently statically set to components and pages)
  • Add support for .ts/.tsx

Changelog

Version 1.1.2

  • Fix an issue where the users' custom config was not imported

Version 1.0.3

  • Add support for generating stories for components (if using Storybook)

Version 1.0.2

  • Add support for the .ts/.tsx extension