Skip to content

esbuild

unplugin-kubb/esbuild runs Kubb as an esbuild plugin. Pass it to the plugins array in your build script.

Install

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

Configure

build.ts
typescript
import { build } from 'esbuild'
import kubb from 'unplugin-kubb/esbuild'
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' } })],
})

await build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outfile: 'dist/bundle.js',
  plugins: [kubb({ config })],
})