Skip to content

Commit

Permalink
docs: unplugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Feb 18, 2024
1 parent bc91613 commit df3e398
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 51 deletions.
22 changes: 22 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ const pluginsSidebar = [
},
],
},
{
text: 'Build plugins',
collapsed: false,
items: [
{
text: 'unplugin-kubb <span class="new">new</span>',
collapsed: false,
link: '/plugins/unplugin/',
},
],
},
{
text: 'Swagger plugins',
collapsed: false,
Expand Down Expand Up @@ -370,6 +381,17 @@ const pluginsMenu = [
},
],
},
{
text: 'Build plugins',
collapsed: false,
items: [
{
text: 'unplugin-kubb',
collapsed: false,
link: '/plugins/unplugin/',
},
],
},
{
text: 'Swagger plugins',
items: [
Expand Down
186 changes: 186 additions & 0 deletions docs/plugins/unplugin/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
---
layout: doc

title: unplugin-kubb
outline: deep
---

# unplugin-kubb <a href="https://paka.dev/npm/unplugin-kubb@latest/api">🦙</a>

Kubb plugin for Vite, Webpack, Esbuild, Rollup, Nuxt, Astro and Rspack.

## Installation

::: code-group

```shell [bun <img src="/feature/bun.svg"/>]
bun add unplugin-kubb @kubb/core
```

```shell [pnpm <img src="/feature/pnpm.svg"/>]
pnpm add unplugin-kubb @kubb/core
```

```shell [npm <img src="/feature/npm.svg"/>]
npm install unplugin-kubb @kubb/core
```

```shell [yarn <img src="/feature/yarn.svg"/>]
yarn add unplugin-kubb @kubb/core
```

:::

## Options

### config

Define the options for Kubb.

::: info type

```typescript [Options]
type Options = {
config: UserConfig
}
```
:::
::: info
Type: `Options` <br/>
::: code-group
```typescript [kubb.config.ts]
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'

/** @type {import('@kubb/core').UserConfig} */
export const config = {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
},
plugins: [
createSwagger({ output: false }),
createSwaggerTS({
output: {
path: 'models',
},
}),
],
}
```

```typescript [vite.config.ts]
import react from '@vitejs/plugin-react'
import kubb from 'unplugin-kubb/vite'
import { defineConfig } from 'vite'
import { config } from './kubb.config'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
kubb({
config,
}),
],
})
```

:::

## Examples

### Vite

```ts
// vite.config.ts
import Plugin from 'unplugin-kubb/vite'

export default defineConfig({
plugins: [
Plugin({/* options */}),
],
})
```

### Rollup

```ts
// rollup.config.js
import Plugin from 'unplugin-kubb/rollup'

export default {
plugins: [
Plugin({/* options */}),
],
}
```

### Webpack

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-kubb/webpack')({/* options */}),
],
}
```

### Nuxt

```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-kubb/nuxt', {/* options */}],
],
})
```

> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
### Vue CLI

```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-kubb/webpack')({/* options */}),
],
},
}
```

### Esbuild

```ts
// esbuild.config.js
import { build } from 'esbuild'
import Plugin from 'unplugin-kubb/esbuild'

build({
plugins: [Plugin()],
})
```

## Depended

- [`@kubb/core`](/plugins/core/)

## Links

- [Vite](https://vitejs.dev/)
10 changes: 5 additions & 5 deletions packages/config/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@
"dependencies": {
"@eslint/js": "^8.56.0",
"@types/eslint": "~8.56.2",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "~6.15.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "~7.0.1",
"eslint-config-prettier": "~9.1.0",
"eslint-config-turbo": "^1.12.4",
"eslint-formatter-pretty": "^6.0.1",
"eslint-plugin-eslint-plugin": "^5.3.0",
"eslint-plugin-import": "~2.29.1",
"eslint-plugin-react": "~7.33.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-turbo": "^1.12.4",
"eslint-plugin-unused-imports": "~3.0.0",
"eslint-plugin-unused-imports": "~3.1.0",
"eslint-plugin-vitest": "~0.3.22",
"eslint-plugin-vitest-globals": "~1.4.0",
"globals": "^13.24.0"
"globals": "^14.0.0"
},
"devDependencies": {
"@kubb/ts-config": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/tsup-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"tsup": "^8.0.2"
},
"peerDependencies": {
"tsup": "^8.0.1"
"tsup": "^8.0.2"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
18 changes: 15 additions & 3 deletions packages/unplugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1>unplugin-kubb</h1>

<p>
Kubb plugin for Vite, webpack, esbuild, Rollup, Nuxt, Astro and Rspack.
Kubb plugin for Vite, Webpack, Esbuild, Rollup, Nuxt, Astro and Rspack.
</p>
<img src="https://raw.githubusercontent.com/kubb-project/kubb/main/assets/banner.png" alt="logo" height="auto" />

Expand Down Expand Up @@ -48,8 +48,6 @@ export default defineConfig({
})
```

Example: [`playground/`](./playground/)

<br></details>

<details>
Expand Down Expand Up @@ -130,6 +128,20 @@ build({

<br></details>

## Options

### config

Define the options for Kubb.

::: info type

```typescript [Options]
type Options = {
config: UserConfig
}
```
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/unplugin-kubb?flat&colorA=18181B&colorB=f58517
Expand Down
Loading

0 comments on commit df3e398

Please sign in to comment.