@whoisryosuke/react-music
v1.0.0
Published
Create code libraries using React, Typescript, and Vite to automatically release to NPM.
Readme
React Vite Library Boilerplate
Create code libraries using React, Typescript, and Vite to automatically release to NPM.
For example, you could create a component library for a design system (so someone can import { ComponentName } from 'your-custom-library').
Getting Started
Preview the code
- Clone this project:
git clone [email protected]:whoisryosuke/react-vite-library-boilerplate.git - Install dependencies:
yarn - Start the dev server:
yarn dev
Open the app in your web browser: http://localhost:5174/
You can also install libraries like Storybook to preview UI components. See
oat-milk-designfor reference.
Write code
Write code in src/ and export any components, functions, etc in the index.ts.
Tips:
- Installing a package? If you don't want to include it in the bundle, install it as a peer dependency and add it to the
vite.config.jsfile and thebuild.rollupOptions.externalarray. You can see we do this with React - since we expect the user to bring their own copy.
Release
First time setup:
- Edit the
package.jsonand changenameto your module's name (anything-dash-separated). Then find and replace the old name with the new name (like themainormoduleproperties). - Go to the project settings and allow Read/Write access for Actions (Settings > Code and Automation > Actions > General - the Workflow permissions part of the page)
- Add your
NPM_TOKENas a repository secret for Actions. Make sure it's a "Granular access token" - the legacy type requires a one-time password (which doesn't work with this workflow).
Using GitHub:
- Run the new version GitHub action. This updates your
package.jsonwith the new version and creates a new tag on GitHub. - Create a new release with the new version tag. This triggers a build that automatically gets pushed to NPM.
Or manually:
- Bump version in
package.json yarn buildnpm publish- Create new tag and release on GitHub.
