vite-library-starter
This is a template repository for Node.js libraries. It has been configured with:
- vite - bundling
- vitest - testing
- typescript - typing
- eslint - linting
- prettier - formatting
- husky - pre-commit hooks
- lint-staged - pre-commit checks
- github actions - deploying
Please read the docs for each for any customizations you need.
I intentionally did not include anything for CSS, or a library such as Vue or React. There are official plugins for most of that, and anything beyond the basics there is, for example, Awesome Vite.js.
Setup
Step 1: Setup new repository
Click Use this template → Create new repository and follow the prompts. Then clone the new repository to your computer.
name
in package.json
Step 2: Change Locally, edit package.json
and replace the name
with your own package name. This can either include a scope, e.g. @scope/package-name
, or omit it, e.g. package-name
. Commit the changes and push the commit. It's usually safer to include a scope to ensure the package name is not taken.
.github/workflows/cd.yml
Step 3: Configure In your new repository on GitHub, click Settings → Secrets and variables → Actions. Here, add new secrets for:
GIT_NAME
- the name Git should use when bumping the version number. I typically set it to "Publish Bot"GIT_EMAIL
- the email Git should use, typically the same email as your GitHub account.NPM_TOKEN
- the npm access token to publish the library. You get this from your npmjs.com account.
README.md
Step 4: Update Update this file with some documentation for your library.
LICENSE
Step 5: Update The default license is the MIT license, but feel free to adjust to your needs. At minimum update the year, if needed, and set <copyright holders>
to your name or organization.
Usage
Day-to-day
The typical. Create a feature branch, commit some changes, make a PR, have checks pass, merge.
Release new version
Create a new release with a semver tag. Use the auto-generate feature to have all PR titles listed.