Beta You're reading the docs for Kubb v5, which is currently in beta. View the stable v4 docs
Skip to content

Run Kubb with Rollup

unplugin-kubb/rollup runs Kubb as a Rollup plugin. It writes the generated files in the buildStart hook, before the rest of the bundle runs. Pass your Kubb config to the config option.

Install

Install the plugin as a dev dependency.

shell
bun add -d unplugin-kubb@beta
shell
pnpm add -D unplugin-kubb@beta
shell
npm install --save-dev unplugin-kubb@beta
shell
yarn add -D unplugin-kubb@beta

Configure

Add the plugin to your rollup.config.ts and pass it your Kubb config.

rollup.config.ts
typescript
import kubb from 'unplugin-kubb/rollup'
import { defineConfig } from 'kubb'
import { pluginTs } from '@kubb/plugin-ts'

const config = defineConfig({
  root: '.',
  input: { path: './petStore.yaml' },
  output: { path: './src/gen', clean: true },
  plugins: [pluginTs({ output: { path: 'models' } })],
})

export default {
  input: 'src/index.ts',
  plugins: [kubb({ config })],
}