Kong OSS Vite Plugins
# pnpm
pnpm add @kong/vite-plugins
# yarn
yarn add @kong/vite-plugins
#npm
npm install @kong/vite-pluginsEach Vite plugin has its own documentation within its parent directory.
Each Vite plugin is exposed at an import path from the @kong/vite-plugins npm package and provide their own exports.
Each plugin can choose to provide a default export, or named exports. Please check the desired plugin's documentation for specific usage instructions.
// Default export example
import KongPluginExampleOne from '@kong/vite-plugins/plugin-example-one'
// Named export example
import { getName } from '@kong/vite-plugins/plugin-example-one'- Each Vite plugin must live in its own directory as a direct child of the
/src/folder. No other top-level files should be placed in the/src/folder. - Each Vite plugin directory and export path should follow the naming convention
plugin-*. Example:plugin-example-name - Plugins must be written in TypeScript and adhere to the configured ESLint ruleset. Additional rules may be extended as needed.
- Each plugin must have a
README.mdfile in the directory to provide usage instructions and other information.
-
Add a new directory inside the
/src/folder, named according to the syntaxplugin-{name}wherenameis a descriptor of what the plugin does, e.g.plugin-example-name. -
Add an
index.tsfile at the root of your plugin directory to serve as the entry file for your plugin. -
Add a
README.mdfile in the new plugin directory to provide usage instructions. -
Add your plugin's entry file path to the array of
entriesin [build.config.ts](./build.config.ts). All plugin exports (both default and named) **must** be defined in theindex.ts` file, regardless of your plugin's structure:export default defineBuildConfig({ entries: [ // ...other entries // Add your plugin to the array, using the directory path you created above. './src/plugin-example-name/index.ts', ], })
-
Update the
package.jsonfileexportsobject for your plugin:
Lint package files, and optionally auto-fix detected issues.
# ESLint only
pnpm lint
# ESLint and fix
pnpm lint:fixUnit tests are run with Vitest.
# Run tests
pnpm test
# Run tests in the Vitest UI
pnpm test:uiBuild for production and inspect the files in the /dist directory.
pnpm buildThis repo uses Conventional Commits.
Commitizen and Commitlint are used to help build and enforce commit messages.
It is highly recommended to use the following command in order to create your commits:
pnpm run commitThis will trigger the Commitizen interactive prompt for building your commit message.
Lefthook is used to manage Git Hooks within the repo.
- A
commit-msghook is automatically setup that enforces commit message stands withcommitlint, seelefthook.yaml - A
pre-pushhook is used that runseslintbefore allowing you to push your changes to the repository
Additionally, CI will use commitlint to validate the commits associated with a PR in the Lint and Validate job.
{ "exports": { // Substitute the directory name you created // for your plugin in the path for `plugin-example-name`. "./plugin-example-name": { "import": "./dist/plugin-example-name/index.mjs", "types": "./dist/plugin-example-name/index.d.ts" } } }