You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add lazy loading plugins documentation and tests
Document the `lazy` field in config page with usage examples showing
how to defer heavy plugin imports using async/await dynamic imports.
Add unit tests for async/await lazy loading patterns and a snap test
that verifies lazy-loaded plugins are applied during vp build.
Copy file name to clipboardExpand all lines: docs/config/index.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,3 +29,66 @@ Vite+ extends the basic Vite configuration with these additions:
29
29
-[`run`](/config/run) for Vite Task
30
30
-[`pack`](/config/pack) for tsdown
31
31
-[`staged`](/config/staged) for staged-file checks
32
+
33
+
## Lazy Loading Plugins
34
+
35
+
When `vite.config.ts` imports heavy plugins at the top level, every `import` is evaluated eagerly, even for commands like `vp lint` or `vp fmt` that don't need those plugins. This can make config loading noticeably slow.
36
+
37
+
The `lazy` field solves this by letting you defer plugin loading into an async function. Plugins provided through `lazy` are only resolved when actually needed:
Plugins returned from `lazy` are appended after any plugins already in the `plugins` array. This lets you keep lightweight plugins inline and defer only the expensive ones:
0 commit comments