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

webpack

unplugin-kubb/webpack runs Kubb during webpack compilation. It requires webpack 5. Pass your Kubb config to the config option.

Install

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

webpack.config.js
javascript
const kubb = require('unplugin-kubb/webpack')
const { defineConfig } = require('kubb')
const { pluginTs } = require('@kubb/plugin-ts')

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

module.exports = {
  plugins: [kubb({ config })],
}