React NPM package boilerplate
Boilerplate for building a react component as NPM package.
⚡️ Build NPM modules for your ReactJS project incredibly fast.
✅ ES5, ES6 compatible
✅ ReactJS ^16.6.1
➡️ How to start?
- Clone project into your working directory using
git clone email@example.com:bllago/react-npm-package-boilerplate.git
git clone https://github.com/bllago/react-npm-package-boilerplate.git
- Switch to the react-npm-package-boilerplate directory
- Open react-npm-package-boilerplate /src/index.js in your favorite IDE and start work on your awesome NPM package
➡️ How to build component?
- Just run
npm run buildor
yarn build. After that, you will see generated index.js file in your root folder (react-npm-package-boilerplate/)
➡️ How to test component locally?
Get your NPM package (project) path. Run
pwdin your terminal and copy path
Create test project. Run:
npx create-react-app my-test-project
- Swith to the my-test-project directory:
yarn add <paste copied path here>
- Import component
import Component from 'react-npm-package-boilerplate'
➡️ How to add peerDependencies?
- Open package.json file, find "peerDependencies" section and add dependencies there
➡️ How to publish NPM package
Inside your root project in the terminal type
then npm will ask for your username, password, and email if you don’t have an account with npm go create one first.
After above command user npm login command so you will be logged in to npm
It will again ask for your account information provide it and after that, we are good to go.
To publish your npm module just type
and you just published your first npm module
If you're reading this, you're awesome! Thank you for helping us make this project great. Here are a few guidelines that will help you along the way.
➡️ Inspired by
This project is licensed under the terms of the MIT license.