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.jsonJavascript/React code: All the code present in the folder
src/libwill be compiled and added to the folderdist.
Yourpackage.jsonhas been set withdist/index.jsas 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.cssThe Playground: the playgrond is used to test your component. the files
src/lib/index.jsxandsrc/styles/index.scssare included in the playground, so you can test your component withnpm startBuilding my component: Start editing your
src/lib/index.jsxandsrc/styles/index.scssto build your component! Once your finish, runnpm run buildto compile your component.
You can publish this entire project. The development dependencies are ignored through .gitignore and .npmignore
Happy hack!