Repository navigation
fix(core): serve devtools under base path - #662
Conversation
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vite-task
@vitejs/devtools-vitest
commit: |
webfansplz
left a comment
There was a problem hiding this comment.
Thanks for tracking this down! The root cause makes sense, and mounting the hub under base is needed too, otherwise regular base: '/foo/' projects would break. In a local nested setup with two Vite servers, the loader now points to the inner hub.
I think the fix can be smaller, though. The main parts to keep are the loader base, the extra hub mount, and the /@id/ prefix. I left some suggestions inline.
Could you also add a test for the nested case, with the inner server in middlewareMode and the parent stripping the prefix? The current tests only cover a standalone server.
Dock iframes and icons still use root paths, so a nested dock loads them from the outer server. That's not new in this PR, so we can handle it separately.
Co-authored-by: Arlo <webfansplz@gmail.com>
Co-authored-by: Arlo <webfansplz@gmail.com>
Description
Hey 👋
This PR makes the dev-mode embedded loader respect Vite's
baseand makes the hub answer underbasetoo.Why
When working on the Storybook integration, I noticed that the Storybook preview was mounting the host app's dock instead of its own which ends up in an infinite reload.
Storybook's Vite plugin starts a second Vite server in
middlewareModewithbase: '/storybook/', and the parent server strips/storybookbefore handing requests over. That inner server has its own hub at/storybook/__devtools/, but its pages still load/__devtools/embedded.js, which is the outer hub (or a 404 if there's none). If the host registers an iframe dock pointing at Storybook, it nests itself endlessly.The issue lies in
DevToolsInjection: it only addsconfig.basewhenconfig.command === 'build', so in serve mode the loader always points at the root.Reporudction
Screen.Recording.2026-12-02.at.13.21.37.mov
open the devtools dock of storybook. it will be linked to the actual devtool of the app rather thean the nested storybook.
Fix screenshot
You can see that the devtools in storybook isn't the one from the app as it doesn't dock Storybook within Storybook
Linked Issues
Additional context