Skip to content
Build tools

Generate code from your API spec with Farm

Add the kubb/farm plugin to farm.config.ts so every Farm build generates code from your API spec with the plugins in your kubb.config.ts.

kubb/farm generates code from your kubb.config.ts once, before farm build continues. It ships with kubb.

Install Kubb and your plugins

Follow Installation.

Add Kubb to farm.config.ts

Pass one config object from your kubb.config.ts as config, not an array or a function.

farm.config.ts
import { defineConfig } from '@farmfe/core'
import kubb from 'kubb/farm'
import config from './kubb.config'

export default defineConfig({
  plugins: [kubb({ config })],
})

Run the build

Run farm build. If Kubb fails, the build fails.

How the build runs Kubb covers defaults, reports, and watch rebuilds.