code-inspector icon indicating copy to clipboard operation
code-inspector copied to clipboard

fix(vite): use Vite root instead of envDir as JetBrains workspace

Open ByteRax opened this issue 3 months ago • 1 comments

Reproduction

  1. Configure Vite with envDir: "./env".
  2. Enable codeInspectorPlugin({ editor: "webstorm", bundler: "vite" }).
  3. Trigger Code Inspector on a DOM element.

Actual behavior

WebStorm opens <project-root>/env as the project/workspace.

Expected behavior

WebStorm should open the Vite project root while still loading environment files from envDir.

Root cause

In the Vite adapter, configResolved stores both config.envDir and config.root. The core click handler currently passes record.envDir to launchIDE as rootDir. launch-ide prioritizes this value as the JetBrains workspace, so a custom Vite envDir becomes the opened project directory.

This is still present on master:

record.envDir = config.envDir || config.root
record.root = config.root

Proposed fix

Use the already recorded Vite root when launching the IDE:

- rootDir: record?.envDir,
+ rootDir: record?.root,

This keeps envDir semantics intact and makes JetBrains IDEs open the actual Vite project root.

Tested locally with @code-inspector/[email protected] and [email protected].

ByteRax avatar Aug 23 '26 11:08 ByteRax

Thanks for your feedback, resolved by #579

zh-lx avatar Aug 24 '26 11:08 zh-lx