Skip to content

feat: add projectRoot option and normalizeForChrome flag to devtools-json plugin #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2025

Conversation

0xTaneja
Copy link
Contributor

@0xTaneja 0xTaneja commented Jul 9, 2025

What’s new

This PR introduces two optional, fully backward-compatible settings to vite-plugin-devtools-json:

Option Type Default Why it matters
projectRoot string config.root Explicit path that will be reported to Chrome DevTools. Handy for monorepos or tools (like Wasp) where the desired workspace folder differs from Vite’s root.
normalizeForChrome boolean true Keeps the current behaviour of rewriting Linux paths to UNC form (\\wsl.localhost\…) so Chrome running on Windows (WSL / Docker Desktop) can mount them. Set to false to skip the rewrite.
// vite.config.ts
import devtoolsJson from 'vite-plugin-devtools-json';

export default defineConfig({
  plugins: [
    devtoolsJson({
      projectRoot: '/abs/path/to/project',
      normalizeForChrome: false,   // opt-out if not needed
    })
  ]
});

Implementation

  • src/index.ts now accepts an options: DevToolsJsonOptions object.
  • When provided, projectRoot overrides automatic root detection.
  • UNC rewrite is done only when normalizeForChrome !== false.
  • Existing uuid handling unchanged.

Tests & build

  • Added two Vitest specs covering the new options.
  • All tests pass and npm run build succeeds.

Motivation

While integrating this plugin into Wasp (our project) we needed:

  1. A stable way to specify the true project root (the generated app lives in a subfolder).
  2. Control over UNC rewriting for CI environments where it isn’t required.

Copy link

google-cla bot commented Jul 9, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@0xTaneja
Copy link
Contributor Author

@bmeurer implemented the path normalization, and being able to set a custom root to the devtools plugin. happy to take feedback and make any changes if any to make this pr merged !!

Copy link
Collaborator

@bmeurer bmeurer left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

Copy link
Collaborator

@bmeurer bmeurer left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@bmeurer bmeurer merged commit 56fc810 into ChromeDevTools:main Jul 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants