In this post, I will walk you through building a React component library using Vite and Tailwind. We will also see how to publish it to npm and use it in a React application. We will integrate auto for versioning and release notes.
Requirements
- We will create a react component library using Vite and Tailwind
- We will publish the component library to npm
- We will publish documentation to GitHub pages using Docusaurus
- Make all this setup in a monorepo built with Lerna
- Automate Release Versioning & Release Notes using auto
Setup
Initialize Codebase
We will use Lerna to set up our codebase and add Docusaurus for documentation.
Create Docusaurus App
Create Vite React App
Run the following command
Change package name
Change the name in package.json to @rcls/elements
(actually to something you like)
Setup scripts
Add the following scripts to root package.json
Test Setup
- Build docs:
npm run docs:build
- Build package:
npm run package:build
- Build everything:
npm run build
If both of these work, then the setup is complete. If anything seems to fail, you can clean the repo and build again using npx lerna clean -y && npm install
Push to Github
Create a github public repo on Github and push the codebase to it, as in the following steps we would be using github actions.
Last updated on