This template is no longer maintained. Consider using a different one or start from scratch.
This is a template repository to quickly set up new vite plugins
- Manage dependencies in a pnpm monorepo
- Preconfigured GitHub workflows for ci and release
- Build dual cjs and esm packages from typescript source with tsup
- Test with vitest
- Release including generated changelogs with atlassian/changesets
- Additional tooling like prettier, eslint, lint-staged already set up
- Issue templates for feature requests and bug reports
You can use this either as a GitHub template or with degit as explained below.
- Create a new GitHub repo based on this template. Use a simple name like
someorg/foo-bar
, where someorg is the same on npm and GitHub - Clone your new repo
- Run
pnpm run setup
in the clone - On first run, a setup-script updates the template with urls and names of your new repo, and install dependencies
- Commit the changes done by the setup-script
- Review project setup
- Add an NPM_TOKEN secret in your GitHub repo settings that allows to publish the npm package
- Create a new empty repo on GitHub
- Run
npx degit svitejs/vite-plugin-template my-project
to copy repo locally - In the local repo, run
git init
andgit remote add origin https://github.com/someorg/foo-bar.git
(Change remote git URL accordingly) - Run
pnpm run setup
- On first run, a setup-script updates the template with urls and names of your new repo, and install dependencies
- Commit the changes done by the setup-script
- Review project setup
- Add an NPM_TOKEN secret in your GitHub repo settings that allows to publish the npm package
- Use branches for development
- Add commits
- Add changeset with
pnpm changeset
- Push branch and open a PR
- Check CI results and merge PR into main
- Release workflow creates a PR "Version Packages (next)" to collect changes to be released
When you're ready to release, remove "private": true
in the main workspace's package.json
and push up the change to auto publish. If there are existing changesets, it will create a "Version Packages (next)" PR instead.
- Merge "Version Packages (next)" PR into main
- Release workflow automatically publishes npm package, creates GitHub release info, and tags the release
NOTE: New workspaces should always have
"private": true
or it will try to publish them.
This template creates an esm-only plugin by default. If you need to support commonjs, follow these steps:
- Update tsup config to include 'cjs' output and enable shims if needed
- Update package.json exports map to add
"require": "./dist/index.cjs"
next to the import mapping