Skip to content

Commit 4407f68

Browse files
committed
docs: add example for async addVitePlugin
1 parent 4b05554 commit 4407f68

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/4.api/5.kit/14.builder.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,18 @@ See [Vite website](https://vite.dev/guide/api-plugin) for more information about
207207

208208
### Parameters
209209

210-
**`pluginOrGetter`**: A Vite plugin instance or an array of Vite plugin instances. If a function is provided, it must return a Vite plugin instance or an array of Vite plugin instances.
210+
**`pluginOrGetter`**: A Vite plugin instance or an array of Vite plugin instances. If a function is provided, it must return a Vite plugin instance or an array of Vite plugin instances. The function can also be async or return a Promise, which is useful for lazy-loading plugins:
211+
212+
```ts twoslash
213+
import { addVitePlugin, defineNuxtModule } from '@nuxt/kit'
214+
215+
export default defineNuxtModule({
216+
setup () {
217+
// Lazy load the plugin - only imported when the build actually runs
218+
addVitePlugin(() => import('my-vite-plugin').then(r => r.default()))
219+
},
220+
})
221+
```
211222
212223
**`options`**: Options to pass to the callback function. This object can have the following properties:
213224
@@ -266,7 +277,7 @@ See [webpack website](https://webpack.js.org/concepts/plugins/) for more informa
266277

267278
### Parameters
268279

269-
**`pluginOrGetter`**: A webpack plugin instance or an array of webpack plugin instances. If a function is provided, it must return a webpack plugin instance or an array of webpack plugin instances.
280+
**`pluginOrGetter`**: A webpack plugin instance or an array of webpack plugin instances. If a function is provided, it must return a webpack plugin instance or an array of webpack plugin instances. The function can also be async or return a Promise, enabling lazy-loading of plugins.
270281

271282
**`options`**: Options to pass to the callback function. This object can have the following properties:
272283

0 commit comments

Comments
 (0)