It creates a library for npm using Creat React App
Download or clone this repository, then build your component!
git clone https://github.com/wviveiro/create-react-component.git my-component
cd my-component
npm install
npm start
-
package.json DO NOT FORGET to change the name of your application on
package.json
-
Javascript/React code: All the code present in the folder
src/lib
will be compiled and added to the folderdist
.
Yourpackage.json
has been set withdist/index.js
as main script. -
Your scss files: All css you need has to be present in the file
src/styles/index.scss
. You can import other scss files in this file if you want to split your code.
The css will be compiled and added to the folderdist/styles/index.css
-
The Playground: the playgrond is used to test your component. the files
src/lib/index.jsx
andsrc/styles/index.scss
are included in the playground, so you can test your component withnpm start
-
Building my component: Start editing your
src/lib/index.jsx
andsrc/styles/index.scss
to build your component! Once your finish, runnpm run build
to compile your component.
You can publish this entire project. The development dependencies are ignored through .gitignore
and .npmignore
Happy hack!