Run Kubb with esbuild#
kubb/esbuild runs Kubb as an esbuild plugin. Add it to the plugins array in your build script. Pass your Kubb config to the config option.
Install#
Install kubb as a dev dependency.
::: code-group
bun add -d kubb
pnpm add -D kubb
npm install --save-dev kubb
yarn add -D kubb
:::
Configure#
Add the plugin to the plugins array in your build script:
import { build } from 'esbuild'
import kubb from 'kubb/esbuild'
import { pluginTs } from '@kubb/plugin-ts'
const config = {
root: '.',
input: './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 })],
})