A minimalistic boilerplate for publishing a React component to NPM:
- No Babel
- No Webpack
- No testing
- No linting
You get to decide how to bring those in yourself if you decide that you need it.
This boilerplate focuses on getting you publishing as fast as possible.
- Clone this repo into a folder of your choice and
cd
into it:
git clone https://github.com/adrianmcli/dev-react-component.git my-new-component
cd my-new-component
- Delete the existing git history by running
rm -rf .git
and then rungit init
to start fresh. - Run
yarn
ornpm install
to install the dependencies. - Change the
name
,version
, anddescription
insidepackage.json
. - Start developing your component inside
src/MyComponent.js
. - Run
npm publish
to publish your component.
This boilerplate makes use of React Build Lib and React Build Dist in order to generate the lib
and dist
folders for distribution. These two tools generate CommonJS and UMD modules respectively. Use of Babel and Webpack is hidden under the hood so that you can concentrate on sharing your component.
Note that these tools are extremely early in their development (i.e. this is as pre-alpha as it gets).