Skip to content

feat(devtools): enable dev server integration - #23333

Merged
sapphi-red merged 15 commits into
vitejs:mainfrom
webfansplz:feat/vite-devtools-dev
Sep 7, 2026
Merged

feat(devtools): enable dev server integration#23333
sapphi-red merged 15 commits into
vitejs:mainfrom
webfansplz:feat/vite-devtools-dev

Conversation

@webfansplz

@webfansplz webfansplz commented Aug 23, 2026

Copy link
Copy Markdown
Member

Background

Vite's experimental devtools option currently supports build-time analysis only. When enabled, Vite loads a single build integration plugin that configures Rolldown analysis and starts Vite DevTools after the build.

Using Vite DevTools during development still requires users to register the DevTools() plugin manually in vite.config.ts. This creates two separate setup paths for development and build analysis.

vitejs/devtools#541 prepares @vitejs/devtools for first-class Vite integration by:

  • adding devtools.apply with 'serve', 'build', and 'all'
  • making DevToolsIntegration() return an async plugin array
  • returning the existing DevTools() plugins in serve mode
  • preserving the existing Rolldown integration in build mode

This PR is the corresponding Vite Core integration for @vitejs/devtools 0.6.0.

Changes

  • Require @vitejs/devtools 0.6.0.
  • Enable the devtools integration for both serve and build.
  • Load the plugin array returned by DevToolsIntegration().
  • Reuse Vite's existing sortUserPlugins() helper to preserve each integration plugin's pre, normal, or post enforcement order.
  • Avoid automatically registering the dev-server integration when the user has already registered DevTools() manually.
  • Support devtools.apply through the resolved DevTools configuration.
  • Treat a DevTools configuration object as enabled unless enabled: false is explicitly set.
  • Update the DevTools playground to install the opt-in Vite inspection integration.
  • Update the documentation to clarify that:
    • @vitejs/devtools-vite is required for dev-server inspection.
    • @vitejs/devtools-rolldown is required for build analysis.
    • DevTools runs during both serve and build by default.

Breaking changes

These changes only affect the experimental devtools option.

  • devtools: true now enables DevTools during both development and production builds. Previously, it only enabled build-time analysis.

    To preserve the previous behavior:

    export default defineConfig({
      devtools: {
        apply: 'build',
      },
    })
  • A DevTools configuration object now enables the integration by default. Previously, an object without enabled: true was treated as disabled.

    Use enabled: false to disable it explicitly:

    export default defineConfig({
      devtools: {
        enabled: false,
      },
    })
  • The minimum supported @vitejs/devtools version is now 0.6.0 because Vite Core relies on the new async plugin-array integration contract.

  • Build analysis and dev-server inspection remain opt-in integrations. Users need to install the corresponding package:

    pnpm add -D @vitejs/devtools @vitejs/devtools-vite

    For build analysis:

    pnpm add -D @vitejs/devtools-rolldown

Screenshot

iShot_2026-08-23_20 34 01

Copilot AI lite review requested due to automatic review settings August 23, 2026 12:42
@webfansplz
webfansplz marked this pull request as draft August 23, 2026 12:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates @vitejs/devtools more deeply into Vite Core so the experimental devtools option can activate DevTools for both dev-server inspection (serve) and build analysis (build), aligning behavior with the new async “plugin array” integration contract introduced in @vitejs/devtools 0.6.0.

Changes:

  • Updates Vite’s DevTools integration to load an async plugin array and preserve pre/normal/post ordering.
  • Changes DevTools enablement semantics so a config object is enabled by default unless enabled: false.
  • Bumps DevTools-related dependencies (plus playground + docs) to @vitejs/devtools ^0.6.0 and adds opt-in integration packages in the playground.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Updates lockfile for @vitejs/devtools@0.6.0 and its new dependency graph.
playground/devtools/vite.config.ts Adjusts playground DevTools config to exercise serve-mode integration via apply: 'serve'.
playground/devtools/package.json Adds @vitejs/devtools-vite and @vitejs/devtools-rolldown to demonstrate opt-in integrations.
packages/vite/src/node/plugins/index.ts Loads DevTools integration as a plugin set and inserts into Vite’s plugin pipeline.
packages/vite/src/node/config.ts Updates DevTools config resolution semantics and carries through apply.
packages/vite/package.json Bumps Vite’s DevTools dependency + peer dependency requirement.
docs/config/shared-options.md Updates docs to reflect serve + build behavior and required opt-in integration packages.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/vite/src/node/plugins/index.ts Outdated
Comment thread packages/vite/package.json
@webfansplz
webfansplz marked this pull request as ready for review August 23, 2026 13:26
Comment thread packages/vite/src/node/plugins/index.ts Outdated
Comment on lines +60 to +64
const isDevToolsPluginRegistered =
config.command === 'serve' &&
[...prePlugins, ...normalPlugins, ...postPlugins].some(
(plugin) => plugin.name === 'vite:devtools:server',
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there a reason for the user to add the devtools plugin manually?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitejs/devtools currently exposes the DevTools() plugin for manual registration. Once dev-mode support is officially available, we can update the docs to recommend the built-in integration for users on Vite 8.3.0+ instead of adding the plugin manually.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean all options in DevTools will be moved to devtools option?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the ideal use case would be

export default defineConfig({
  devtools: true,
  plugins: [
    // ideally no manually ViteDevTools()
    VueDevTools(),
    NuxtDevTools(),
    XxxDevTools(),
  ]
})

@sapphi-red sapphi-red added the p3-significant High priority enhancement (priority) label Aug 24, 2026
@sapphi-red sapphi-red added this to the 8.3 milestone Aug 24, 2026
@sapphi-red

Copy link
Copy Markdown
Member

I'm finding some problems with the current structure:

  • The option exists in both the plugin and in core (devtools option)
    • If the user wants to configure the option that only exists in the plugin, the user would need to add the plugin
  • A change in ResolvedDevToolsConfig requires a Vite upgrade even if it's an addition

@webfansplz

Copy link
Copy Markdown
Member Author

I'm finding some problems with the current structure:

  • The option exists in both the plugin and in core (devtools option)

    • If the user wants to configure the option that only exists in the plugin, the user would need to add the plugin
  • A change in ResolvedDevToolsConfig requires a Vite upgrade even if it's an addition

Good catch, I'll improve them.

Comment thread packages/vite/src/node/plugins/index.ts Outdated

@sapphi-red sapphi-red left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the option lives in Vite, I guess the complexity around the plugin resolution is inevitable.
@bluwy Do you have any thoughts?

Comment thread packages/vite/src/node/config.ts Outdated
Comment thread packages/vite/src/node/config.ts Outdated
Comment thread packages/vite/src/node/config.ts Outdated
@antfu

antfu commented Sep 1, 2026

Copy link
Copy Markdown
Member

My high-level instinct is that we should have as little logic on the Vite side as possible to decouple Vite and Vite DevTools, so they can keep evolving without trapping each other. If the config hook changing the devtools option would make the whole resolution complex, I wonder if we should not allow user plugins to enable/disable devtools, but only allow the user config to control it.

Imagine a case where a user has the Vue DevTools plugin installed in the plugins list, but has devtools: false in the same thing; I think it would make more sense for Vue DevTools to be disabled, respecting the user's option. On the contrary, I don't see much sense in a plugin to enable the DevTools for users (by mutating the devtools option). Plugins could print a warning saying "XXX DevTools is disabled, as the Vite DevTools is not persent, to enable it, set devtools: true in the vite.config.ts" or so.

@webfansplz

webfansplz commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

Thanks @antfu and @sapphi-red — I’ve updated both implementations based on your feedback.

Changes in this PR:

  • DevTools integration plugins are now added alongside user plugins before sortUserPlugins(), so they follow the standard apply, enforce, config, and configResolved lifecycle.
  • The automatic integration is determined exclusively from the top-level user devtools option. Plugin config hooks can’t enable, disable, or mutate it, removing the timing ambiguity around whether DevTools should be loaded.
  • Build-time startup no longer depends on plugin ordering. Vite calls builder.runDevTools() after the application and fallback environments have finished building.
  • Vite delegates option normalization and integration behavior to the installed @vitejs/devtools version instead of maintaining its own resolved configuration.
  • The Vite PR now uses the pkg.pr.new build from bff0115.

Changes in vitejs/devtools#549:

  • The integration returns regular Vite plugins for both serve and build modes.
  • runDevTools() checks for the build integration plugin before starting standalone DevTools, avoiding extra state or plugin-order assumptions.
  • Duplicate registration is detected on the DevTools side, covering both multiple manual DevTools() instances and automatic plus manual registration.
  • Using only the manual DevTools() plugin remains supported when the core option is disabled or not configured.

Please give this a final check. If everything looks good, I’ll release Vite DevTools 0.7 and mark this PR as ready to merge. 🙏

@sapphi-red

Copy link
Copy Markdown
Member

I don't see much sense in a plugin to enable the DevTools for users

I was thinking of a case where a meta-framework wants to change the value, but that reasoning makes sense to me.

Comment thread docs/config/shared-options.md
Comment thread packages/vite/src/node/__tests__/config.spec.ts Outdated
Comment thread packages/vite/src/node/plugins/index.ts Outdated
Comment thread packages/vite/src/node/config.ts Outdated
Comment thread packages/vite/src/node/config.ts Outdated
Comment thread playground/devtools/vite.config.ts
Comment thread packages/vite/src/node/config.ts
@bluwy

bluwy commented Sep 3, 2026

Copy link
Copy Markdown
Member

As long as the option lives in Vite, I guess the complexity around the plugin resolution is inevitable.
@bluwy Do you have any thoughts?

I'm not really sure what you mean. I guess the PR has changed since you last commented. The current structure of how the types is re-exported seems fine to me though.

@webfansplz
webfansplz marked this pull request as ready for review September 3, 2026 09:07

@sapphi-red sapphi-red left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, after your update, I noticed about this and was thinking of how to solve it:
https://github.com/vitejs/vite/pull/23333/changes#r3923113643

Comment thread packages/vite/src/node/config.ts Outdated
Comment thread packages/vite/src/node/config.ts Outdated
Comment thread packages/vite/src/node/config.ts Outdated
@sapphi-red

Copy link
Copy Markdown
Member

As long as the option lives in Vite, I guess the complexity around the plugin resolution is inevitable.
@bluwy Do you have any thoughts?

I'm not really sure what you mean. I guess the PR has changed since you last commented. The current structure of how the types is re-exported seems fine to me though.

The problem there was the following circular dep:

  • devtools plugin should be added before config hooks as all plugins should be listed in the config hook
  • devtools plugin should only be loaded if the devtools option is enabled
  • whether the devtools option is enabled relies on the config hook

The original implementation solved this by breaking the first point. Anthony's suggestion solved this by breaking the third point.

@webfansplz

Copy link
Copy Markdown
Member Author

Thanks for the thorough review, @sapphi-red! I’ve addressed all your feedback. Could you take one final look?

export type {
DevToolsConfig,
ResolvedDevToolsConfig,
} from '@vitejs/devtools/config'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea about this, since @vitejs/devtools deps on vite while vite is not depend directly on @vitejs/devtools, what we can do is that we define an empty config interface in Vite:

// Augment by `@vitejs/devtools`
export interface DevToolsConfig {}
export interface ResolvedDevToolsConfig {}

and in @vitejs/devtools, we do

declare module 'vite' {
  interface DevToolsConfig {
    foo: string,
    bar: ...
  }

  interface ResolvedDevToolsConfig {}
}

I don't know which approach would be more robust, just an idea I haven't tested

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is better if we can remove all @vitejs/devtools import from Vite core. But since that exists, we need to keep @vitejs/devtools as a peer dep, so I think it won't simplify much.

antfu
antfu previously approved these changes Sep 3, 2026

@antfu antfu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this LGTM, thanks!

sapphi-red
sapphi-red previously approved these changes Sep 3, 2026

@sapphi-red sapphi-red left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sapphi-red

Copy link
Copy Markdown
Member

/ecosystem-ci run

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/plugin-legacy

pnpm add https://pkg.pr.new/@vitejs/plugin-legacy@23333 -D
npm i https://pkg.pr.new/@vitejs/plugin-legacy@23333 -D
yarn add https://pkg.pr.new/@vitejs/plugin-legacy@23333.tgz -D

vite

pnpm add https://pkg.pr.new/vite@23333 -D
npm i https://pkg.pr.new/vite@23333 -D
yarn add https://pkg.pr.new/vite@23333.tgz -D

commit: 8d6ae3d

@sapphi-red

Copy link
Copy Markdown
Member

/ecosystem-ci run vite-plugin-svelte

@vite-ecosystem-ci

Copy link
Copy Markdown

📝 Ran ecosystem CI on 047bf9c: Open

suite result latest scheduled
vite-plugin-svelte success failure

@vite-ecosystem-ci

Copy link
Copy Markdown

📝 Ran ecosystem CI on 047bf9c: Open

suite result latest scheduled
marko success failure
vite-plugin-cloudflare success failure
storybook success failure
vinext success failure
netlify-vite-plugin failure failure
nitro success failure
tanstack-start ⏹️ cancelled failure
analogjs success failure
vite-plugin-rsc failure failure
qwik failure failure
vite-plugin-vue success failure
module-federation success failure
vite-plugin-svelte failure failure
vite-plugin-pwa success failure
laravel failure failure
astro success failure
sveltekit failure failure
vuepress success failure
quasar success failure
vitepress success failure
nuxt success failure
vite-plugin-laravel failure failure
vite-setup-catalogue success failure
react-router failure failure
vite-environment-examples failure failure
vite-plugin-react success failure
vike success failure
waku failure failure
vitest failure failure
unocss success failure

@sapphi-red
sapphi-red merged commit 68aeb8a into vitejs:main Sep 7, 2026
19 checks passed
@webfansplz
webfansplz deleted the feat/vite-devtools-dev branch September 7, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p3-significant High priority enhancement (priority) trigger: preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants