Generate code from your API spec with Rollup
kubb/rollup generates code from your kubb.config.ts once, before the Rollup build continues. It ships with kubb.
Install Kubb and your plugins
Follow Installation. Add @rollup/plugin-typescript, tslib, and typescript to your dev dependencies, so Rollup can compile src/index.ts and rollup.config.ts.
Add Kubb to rollup.config.ts
Pass one config object from your kubb.config.ts as config, not an array or a function.
import typescript from '@rollup/plugin-typescript'
import kubb from 'kubb/rollup'
import config from './kubb.config.ts'
export default {
input: 'src/index.ts',
plugins: [kubb({ config }), typescript()],
}Add rollup.config.ts to the include of tsconfig.json, such as "include": ["src/**/*", "rollup.config.ts"], so the TypeScript plugin can compile it.
Run the build
Run rollup -c rollup.config.ts --configPlugin typescript. Rollup loads only .js, .mjs, and .cjs config files by default, so --configPlugin typescript compiles the config first. If Kubb fails, the build fails.
How the build runs Kubb covers defaults, reports, and watch rebuilds.
