[{"data":1,"prerenderedAt":438},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools":3},{"id":4,"title":5,"body":6,"description":419,"extension":420,"frontmatter":421,"heading":428,"meta":429,"navigation":431,"order":414,"path":432,"seo":433,"sitemap":434,"source":435,"stem":436,"__hash__":437},"docs\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools.md","Build tool plugins - Generate code during a build",{"type":7,"value":8,"toc":412},"minimark",[9,29,33,42,61,247,252,300,304,318,364,401],[10,11,12,16,17,20,21,24,25,28],"p",{},[13,14,15],"code",{},"unplugin-kubb"," runs your ",[13,18,19],{},"kubb.config.ts"," when a build starts. It ships with ",[13,22,23],{},"kubb",", and you import it from ",[13,26,27],{},"kubb\u002F\u003Ctool>",".",[30,31],"mermaid",{"svg":32},"\u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" class=\"pele pele-sequence\" viewBox=\"0 0 434 314\" width=\"434\" height=\"314\" style=\"--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,monospace);font:16px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,sans-serif)\" fill=\"var(--_fg)\" role=\"graphics-document document\" aria-roledescription=\"sequence\">\u003Cg transform=\"translate(56.9,8)\">\u003Cg class=\"pele-lifelines\" fill=\"none\" stroke=\"var(--_b)\">\u003Cpath class=\"pele-lifeline\" data-id=\"B\" d=\"M0,44V254\"\u002F>\u003Cpath class=\"pele-lifeline\" data-id=\"U\" d=\"M155.15,44V254\"\u002F>\u003Cpath class=\"pele-lifeline\" data-id=\"K\" d=\"M333.88,44V254\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edges\" fill=\"none\" stroke=\"var(--_l)\" stroke-linecap=\"round\">\u003Cg class=\"pele-edge pele-message\" data-id=\"i0\">\u003Cpath d=\"M0,87H148.15\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M155.15,87L147.15,90.36L147.15,83.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge pele-message\" data-id=\"i1\">\u003Cpath d=\"M155.15,101H177.15A6,6 0 0 1 183.15,107V117A6,6 0 0 1 177.15,123H162.15\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M155.15,123L163.15,119.64L163.15,126.36Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge pele-message\" data-id=\"i2\">\u003Cpath d=\"M155.15,160H326.88\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M333.88,160L325.88,163.36L325.88,156.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge pele-message\" data-id=\"i3\">\u003Cpath d=\"M333.88,197H162.15\" stroke-dasharray=\"4 4\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M155.15,197L163.15,193.64L163.15,200.36Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge pele-message\" data-id=\"i4\">\u003Cpath d=\"M155.15,234H7\" stroke-dasharray=\"4 4\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M0,234L8,230.64L8,237.36Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003C\u002Fg>\u003Cg class=\"pele-edge-labels\" font-size=\"14\">\u003Cg class=\"pele-edge-label\" data-id=\"i0\">\u003Ctext x=\"77.58\" y=\"77.4\" text-anchor=\"middle\">build starts\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-edge-label\" data-id=\"i1\">\u003Ctext x=\"249.52\" y=\"116.9\" text-anchor=\"middle\">load kubb.config.ts\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-edge-label\" data-id=\"i2\">\u003Ctext x=\"244.52\" y=\"150.4\" text-anchor=\"middle\">generate\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-edge-label\" data-id=\"i3\">\u003Ctext x=\"244.52\" y=\"187.4\" text-anchor=\"middle\">files written\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-edge-label\" data-id=\"i4\">\u003Ctext x=\"77.58\" y=\"224.4\" text-anchor=\"middle\">build continues\u003C\u002Ftext>\u003C\u002Fg>\u003C\u002Fg>\u003Cg class=\"pele-nodes\">\u003Cg class=\"pele-node pele-actor pele-actor-participant pele-actor-footer\" data-id=\"B\">\u003Crect x=\"-48.9\" y=\"254\" width=\"97.81\" height=\"44\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"281.6\" text-anchor=\"middle\">Build tool\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-actor pele-actor-participant pele-actor-footer\" data-id=\"U\">\u003Crect x=\"88.9\" y=\"254\" width=\"132.5\" height=\"44\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"155.15\" y=\"281.6\" text-anchor=\"middle\">unplugin-kubb\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-actor pele-actor-participant pele-actor-footer\" data-id=\"K\">\u003Crect x=\"299.2\" y=\"254\" width=\"69.36\" height=\"44\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"333.88\" y=\"281.6\" text-anchor=\"middle\">Kubb\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-actor pele-actor-participant\" data-id=\"B\">\u003Crect x=\"-48.9\" y=\"0\" width=\"97.81\" height=\"44\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"27.6\" text-anchor=\"middle\">Build tool\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-actor pele-actor-participant\" data-id=\"U\">\u003Crect x=\"88.9\" y=\"0\" width=\"132.5\" height=\"44\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"155.15\" y=\"27.6\" text-anchor=\"middle\">unplugin-kubb\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-actor pele-actor-participant\" data-id=\"K\">\u003Crect x=\"299.2\" y=\"0\" width=\"69.36\" height=\"44\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"333.88\" y=\"27.6\" text-anchor=\"middle\">Kubb\u003C\u002Ftext>\u003C\u002Fg>\u003C\u002Fg>\u003C\u002Fg>\u003C\u002Fsvg>",[34,35,37,38,41],"blockquote",{"as":36},"important","Vite, Nuxt, and Astro generate during builds only, not in their dev servers. Run ",[13,39,40],{},"kubb generate"," before you start a dev server.",[10,43,44,45,47,48,51,52,54,55,57,58,28],{},"Each tool page passes your ",[13,46,19],{}," as ",[13,49,50],{},"config",". Without ",[13,53,50],{},", the plugin finds ",[13,56,19],{}," like the CLI does and builds every config in it that has an ",[13,59,60],{},"input",[62,63,64,80],"table",{},[65,66,67],"thead",{},[68,69,70,74,77],"tr",{},[71,72,73],"th",{},"Tool",[71,75,76],{},"Import",[71,78,79],{},"Config file",[81,82,83,103,121,139,157,175,193,211,229],"tbody",{},[68,84,85,93,98],{},[86,87,88],"td",{},[89,90,92],"a",{"href":91},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Fvite","Vite",[86,94,95],{},[13,96,97],{},"kubb\u002Fvite",[86,99,100],{},[13,101,102],{},"vite.config.ts",[68,104,105,111,116],{},[86,106,107],{},[89,108,110],{"href":109},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Fwebpack","webpack",[86,112,113],{},[13,114,115],{},"kubb\u002Fwebpack",[86,117,118],{},[13,119,120],{},"webpack.config.ts",[68,122,123,129,134],{},[86,124,125],{},[89,126,128],{"href":127},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Frspack","Rspack",[86,130,131],{},[13,132,133],{},"kubb\u002Frspack",[86,135,136],{},[13,137,138],{},"rspack.config.ts",[68,140,141,147,152],{},[86,142,143],{},[89,144,146],{"href":145},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Frollup","Rollup",[86,148,149],{},[13,150,151],{},"kubb\u002Frollup",[86,153,154],{},[13,155,156],{},"rollup.config.ts",[68,158,159,165,170],{},[86,160,161],{},[89,162,164],{"href":163},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Frolldown","Rolldown",[86,166,167],{},[13,168,169],{},"kubb\u002Frolldown",[86,171,172],{},[13,173,174],{},"rolldown.config.ts",[68,176,177,183,188],{},[86,178,179],{},[89,180,182],{"href":181},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Fesbuild","esbuild",[86,184,185],{},[13,186,187],{},"kubb\u002Fesbuild",[86,189,190],{},[13,191,192],{},"build.ts",[68,194,195,201,206],{},[86,196,197],{},[89,198,200],{"href":199},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Ffarm","Farm",[86,202,203],{},[13,204,205],{},"kubb\u002Ffarm",[86,207,208],{},[13,209,210],{},"farm.config.ts",[68,212,213,219,224],{},[86,214,215],{},[89,216,218],{"href":217},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Fnuxt","Nuxt",[86,220,221],{},[13,222,223],{},"kubb\u002Fnuxt",[86,225,226],{},[13,227,228],{},"nuxt.config.ts",[68,230,231,237,242],{},[86,232,233],{},[89,234,236],{"href":235},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools\u002Fastro","Astro",[86,238,239],{},[13,240,241],{},"kubb\u002Fastro",[86,243,244],{},[13,245,246],{},"astro.config.mjs",[248,249,251],"h2",{"id":250},"how-the-build-runs-kubb","How the build runs Kubb",[253,254,255,278,295],"ul",{},[256,257,258,259,47,263,266,267,270,271,274,275,28],"li",{},"The plugin applies the same ",[89,260,262],{"href":261},"\u002Fdocs\u002F5.x\u002Freference\u002Fconfiguration#defaults","defaults",[13,264,265],{},"defineConfig"," and runs ",[13,268,269],{},"output.format",", ",[13,272,273],{},"output.lint",", and ",[13,276,277],{},"output.postGenerate",[256,279,280,281,270,284,287,288,291,292,294],{},"It prints the run summary, not the ",[13,282,283],{},"json",[13,285,286],{},"file",", or ",[13,289,290],{},"html"," reports. Use ",[13,293,40],{}," for those.",[256,296,297,298,28],{},"Watch rebuilds reuse the first output. Restart the build after you change the spec or ",[13,299,19],{},[248,301,303],{"id":302},"import-a-spec","Import a spec as a module",[10,305,306,307,309,310,313,314,317],{},"Import a config's ",[13,308,60],{}," file, or any ",[13,311,312],{},"*.openapi.yaml"," or ",[13,315,316],{},"*.openapi.yml"," file, to get the output of every plugin in your config as one module. Kubb writes no files for it, and it works in the Vite dev server too.",[319,320,325],"pre",{"language":321,"filename":322,"code":323,"class":324},"ts","src\u002Fpets.ts","import { type Pet, petStatusEnum } from '.\u002FpetStore.openapi.yaml'","highlights",[13,326,328],{"class":327},"language-ts",[329,330,333,337,341,344,348,350,354,357,360],"span",{"class":331,"style":332},"line","display: inline",[329,334,336],{"style":335},"color:#d73a49;--hls-dark:#f97583","import ",[329,338,340],{"style":339},"color:#005cc5;--hls-dark:#79b8ff","{ ",[329,342,343],{"style":335},"type ",[329,345,347],{"style":346},"color:#6f42c1;--hls-dark:#b392f0","Pet",[329,349,270],{"style":335},[329,351,353],{"style":352},"color:#24292e;--hls-dark:#e1e4e8","petStatusEnum ",[329,355,356],{"style":339},"} ",[329,358,359],{"style":335},"from ",[329,361,363],{"style":362},"color:#032f62;--hls-dark:#9ecbff","'.\u002FpetStore.openapi.yaml'",[253,365,366,378,381],{},[256,367,368,369,371,372,374,375,377],{},"The import uses the config whose ",[13,370,60],{}," is that spec, or else the first config without an ",[13,373,60],{},". A config without ",[13,376,60],{}," only serves imports.",[256,379,380],{},"Code a plugin writes to a separate file, such as a bundled client runtime, is not part of the module.",[256,382,383,384,386,387,390,391,393,394,397,398,400],{},"The ",[13,385,60],{}," file loads whatever its name, so ",[13,388,389],{},".\u002Fmy-api.openapi.json"," works when it is a config's ",[13,392,60],{},". openapi-import gives no types for a ",[13,395,396],{},".json"," import, because TypeScript does not let a content mapper register a ",[13,399,396],{}," extension.",[10,402,403,404,407,408,28],{},"For types in ",[13,405,406],{},"tsc"," and your editor, add ",[89,409,411],{"href":410},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fopenapi-import","openapi-import",{"title":413,"searchDepth":414,"depth":414,"links":415},"",5,[416,418],{"id":250,"depth":417,"text":251},2,{"id":302,"depth":417,"text":303},"Run your kubb.config.ts from Vite, webpack, Rollup, Rolldown, Rspack, esbuild, Farm, Nuxt, or Astro with unplugin-kubb, so every build generates code from your API spec.","md",{"layout":422,"title":5,"description":419,"outline":423,"order":414,"navigation":425},"doc",[417,424],3,{"title":426,"icon":427},"Build tools","i-iconoir-hammer","Build tool plugins",{"layout":422,"outline":430},[417,424],{"title":426,"icon":427},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools",{"title":5,"description":419},{"loc":432},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Fintegrations\u002Fbuild-tools.md","docs\u002F5.x\u002Fintegrations\u002Fbuild-tools","zjZEDgAnnKdp368Els5bFeUvZVi_BzysFssEXtY4o2o",1795021319139]