devtools icon indicating copy to clipboard operation
devtools copied to clipboard

`vite build` starts one standalone DevTools server per build environment

Open RaphaelFakhri opened this issue 1 month ago • 0 comments

Describe the bug

When DevTools is enabled through the Vite config (devtools: { ... }), vite build calls runDevTools(builder) once after buildApp(). runDevTools in packages/core/src/node/plugins/integration.ts loops over the selected build environments and calls startDevTools() on each iteration, but the loop variable is unused. Every call starts an identical standalone server for the whole project.

A build with more than one environment (for example client + ssr, as in SSR apps and most meta-frameworks) therefore starts several DevTools servers on consecutive ports, each printing its own banner:

vite v8.3.4 building client environment for production...
vite v8.3.4 building ssr environment for production...
⬢ Vite DevTools started at http://localhost:9999
⬢ Vite DevTools started at http://localhost:10000

Expected: one DevTools server per build.

Reproduction

vite.config.mjs:

export default {
  devtools: { builtinDevTools: false },
  builder: {},
  environments: {
    client: {},
    ssr: { build: { outDir: 'dist/server', rollupOptions: { input: './main.js' } } },
  },
}

With index.html and main.js next to it, run vite build (Vite 8.3.4, @vitejs/devtools 0.7.6). Two DevTools servers start.

System info

Linux, Node.js 24.16.0, pnpm 12.11.2.

RaphaelFakhri avatar Oct 18 '26 11:10 RaphaelFakhri