Skip to content

Run Kubb with webpack

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

Install

Install kubb as a dev dependency.

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

Configure

Add the plugin to your webpack.config.js:

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

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

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