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: update Vite DevTools Kit skills with recent features
Add comprehensive documentation for:
- Logs & notifications system (fire-and-forget, handles, deduplication, toasts)
- Launcher dock entry type (setup cards for initialization)
- Self-Inspect debugging plugin (@vitejs/devtools-self-inspect)
- Updated field name reference (source → from) in docs
- Launcher usage in dock-entry-types.md and badge property
- Setup-time shared state initialization
- Example plugin references for agents and developers
Also create new logs-patterns.md reference file with complete patterns and examples.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Creates devtools integrations for Vite using @vitejs/devtools-kit.
5
5
Use when building Vite plugins with devtools panels, RPC functions,
6
-
dock entries, shared state, or any devtools-related functionality.
7
-
Applies to files importing from @vitejs/devtools-kit or containing
8
-
devtools.setup hooks in Vite plugins.
6
+
dock entries, shared state, logs/notifications, or any devtools-related
7
+
functionality. Applies to files importing from @vitejs/devtools-kit or
8
+
containing devtools.setup hooks in Vite plugins.
9
9
---
10
10
11
11
# Vite DevTools Kit
@@ -18,10 +18,11 @@ A DevTools plugin extends a Vite plugin with a `devtools.setup(ctx)` hook. The c
18
18
19
19
| Property | Purpose |
20
20
|----------|---------|
21
-
|`ctx.docks`| Register dock entries (iframe, action, custom-render) |
21
+
|`ctx.docks`| Register dock entries (iframe, action, custom-render, launcher) |
22
22
|`ctx.views`| Host static files for UI |
23
23
|`ctx.rpc`| Register RPC functions, broadcast to clients |
24
24
|`ctx.rpc.sharedState`| Synchronized server-client state |
25
+
|`ctx.logs`| Emit structured log entries and toast notifications |
25
26
|`ctx.viteConfig`| Resolved Vite configuration |
26
27
|`ctx.viteServer`| Dev server instance (dev mode only) |
27
28
|`ctx.mode`|`'dev'` or `'build'`|
@@ -123,6 +124,7 @@ export default function myAnalyzer(): Plugin {
123
124
|`iframe`| Full UI panels, dashboards (most common) |
124
125
|`action`| Buttons that trigger client-side scripts (inspectors, toggles) |
125
126
|`custom-render`| Direct DOM access in panel (framework mounting) |
127
+
|`launcher`| Actionable setup cards for initialization tasks |
126
128
127
129
### Iframe Entry
128
130
@@ -166,6 +168,89 @@ ctx.docks.register({
166
168
})
167
169
```
168
170
171
+
### Launcher Entry
172
+
173
+
```ts
174
+
const entry =ctx.docks.register({
175
+
id: 'my-setup',
176
+
title: 'My Setup',
177
+
icon: 'ph:rocket-launch-duotone',
178
+
type: 'launcher',
179
+
launcher: {
180
+
title: 'Initialize My Plugin',
181
+
description: 'Run initial setup before using the plugin',
182
+
buttonStart: 'Start Setup',
183
+
buttonLoading: 'Setting up...',
184
+
onLaunch: async () => {
185
+
// Run initialization logic
186
+
},
187
+
},
188
+
})
189
+
```
190
+
191
+
## Logs & Notifications
192
+
193
+
Plugins can emit structured log entries from both server and client contexts. Logs appear in the built-in **Logs** panel and can optionally show as toast notifications.
Use `@vitejs/devtools-self-inspect` to debug your DevTools plugin. It shows registered RPC functions, dock entries, client scripts, and plugins in a meta-introspection UI at `/.devtools-self-inspect/`.
7.**Deduplicate logs** - Use explicit `id` for logs representing ongoing operations
421
+
8.**Use Self-Inspect** - Add `@vitejs/devtools-self-inspect` during development to debug your plugin
422
+
423
+
## Example Plugins
424
+
425
+
Real-world example plugins in the repo — reference their code structure and patterns when building new integrations:
426
+
427
+
-**A11y Checker** ([`examples/plugin-a11y-checker`](https://github.com/vitejs/devtools/tree/main/examples/plugin-a11y-checker)) — Action dock entry, client-side axe-core audits, logs with severity levels and element positions, log handle updates
0 commit comments