Run Kubb with Rollup
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 kubb as a dev dependency.
shell
bun add -d kubb@betashell
pnpm add -D kubb@betashell
npm install --save-dev kubb@betashell
yarn add -D kubb@betaConfigure
Add the plugin to your rollup.config.ts and pass it your Kubb config.
typescript
import kubb from 'kubb/rollup'
import { pluginTs } from '@kubb/plugin-ts'
const config = {
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 })],
}