- Template for react library package
-
react
-
typescript
-
rollup
-
storybook
-
eslint
-
prettier
- node >= 16
- for ui library -> use storybook
- for library -> remove storybook
- export files
// src/index.ts
// export files here
export { default as Button } from '~~`;
export { default as Radio } from '~~';
export const colors = { ... };
- set token at github repository or make .npmrc file at rook and set token
// .npmrc for github package
//npm.pkg.github.com/:_authToken=ghp_xxxxxxs
- edit publish.yml
// .github/worksflows/publish.yml
// 1. publish on github package
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
...
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
// 2. publish on npm package
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
...
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- change package.json's version before merge to main
// package.json
{
...
"version": "x.x.x"
}
- make release at github, then publish on github or npm by action