A minimal React Typecript library boilerplate boostrapped by using Vite and Vitest.
- React, Typescript
- Eslint, Prettier
- Vite (Library Mode)
- Vitest, React Testing Library
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
The page will reload when you make changes.\
Builds the library for production to the dist
folder.
It uses the Vite Library mode to bundle up everything in the lib
folder, which will be used for publishing to npm.
Lint all files with the extension ts
and tsx
with eslint
Format all files with the extension ts
, tsx
and json
with prettier
Run unit tests
Run tests coverage
- Run
yarn pack
, this will generate a file likeyour-library-v0.0.1.tgz
- Run
yarn add ./your-library-v0.0.1.tgz
, this will add theyour-library
package as a dependency in your local environment. - Run
yarn dev
and change the files import from@lib
toyour-library
, this will allow the local dev to use the packaged library.
Note: If you run into issues, e.g. not seeing the latest changes reflected in the package. Try the following steps:
- Remove the
.tgz
file and remove theyour-library
from thepackage.json
- Remove all
node_modules
- Clear cache,
yarn cache clean your-library
, verify it withyarn cache list --pattern your-library
- Repeat the steps above, e.g. generate a new
.tgz
file and install - Don't forget to install all node modules as well