-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
docs: guide for Chrome DevTools workspace mapping with Vite-Plugin-Devtools-Json #3103
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
base: main
Are you sure you want to change the base?
Conversation
@cprecioso back to business !! PR added , was going to add images and videos but as you said on discord , so made it as a subpart but better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @0xTaneja, thanks for the great work!
I tried it out and left some comments, I think it's ready to merge once you solve those.
Just a note for the future, when writing docs, remember to try out what you're writing and checking that it is correct! (It's a lesson I also had to learn myself 😅) I found some places where the instructions were wrong.
I suggested the necessary fixes myself now, because this relies on a development version of Wasp so it's more difficult to test, but remember for the future!
All in all, great work, thanks a bunch Rushab 🙏
</TabItem> | ||
</Tabs> | ||
|
||
## Chrome DevTools automatic workspace mapping {#devtools-workspace} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 3 ###
, also changed a bit the name so it is more clear what it accomplishes
## Chrome DevTools automatic workspace mapping {#devtools-workspace} | |
### Editing from the Chrome DevTools {#devtools-workspace} |
|
||
## Chrome DevTools automatic workspace mapping {#devtools-workspace} | ||
|
||
Want edits you make in Chrome DevTools Sources panel to save directly to your project files? You can enable [Chrome DevTools Workspace](https://developer.chrome.com/docs/devtools/workspace/) support in development with the community plugin **vite-plugin-devtools-json** (no Wasp fork required). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrote it a bit. We tell people want they can accomplish, and what they'll have to do to accomplish it. This way docs are super nice to read! I also added a link to the plugin's page.
Want edits you make in Chrome DevTools Sources panel to save directly to your project files? You can enable [Chrome DevTools Workspace](https://developer.chrome.com/docs/devtools/workspace/) support in development with the community plugin **vite-plugin-devtools-json** (no Wasp fork required). | |
Chrome DevTools support [mapping a page's resources to a folder](https://developer.chrome.com/docs/devtools/workspaces), so any changes you make in the browser reflect back to your files. To enable it, you can add their Vite plugin: [`vite-plugin-devtools-json`](https://github.com/ChromeDevTools/vite-plugin-devtools-json). |
<Tabs groupId="js-ts"> | ||
<TabItem value="js" label="JavaScript"> | ||
|
||
```js title="vite.config.js" | ||
import { devtoolsJson } from 'vite-plugin-devtools-json' | ||
|
||
export default { | ||
plugins: [ | ||
react(), // already present | ||
devtoolsJson({ | ||
// tell Chrome which folder to map – project root works great | ||
root: __dirname | ||
}) | ||
] | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="ts" label="TypeScript"> | ||
|
||
```ts title="vite.config.ts" | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react-swc' | ||
import { devtoolsJson } from 'vite-plugin-devtools-json' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
react(), | ||
devtoolsJson({ root: __dirname }) | ||
] | ||
}) | ||
``` | ||
</TabItem> | ||
</Tabs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
We have a plugin that lets us write only the TS version and converts it to JS automatically. You just write a normal code block and add the
auto-js
attribute to it. -
This file is an ES Module, not a CommonJS file, so
__dirname
is not the recommended way to get the dirname. We should useimport.meta.dirname
instead. -
We don't require users to add the
react()
plugin, that should be taken out. -
devtoolsJson
is a default export
<Tabs groupId="js-ts"> | |
<TabItem value="js" label="JavaScript"> | |
```js title="vite.config.js" | |
import { devtoolsJson } from 'vite-plugin-devtools-json' | |
export default { | |
plugins: [ | |
react(), // already present | |
devtoolsJson({ | |
// tell Chrome which folder to map – project root works great | |
root: __dirname | |
}) | |
] | |
} | |
``` | |
</TabItem> | |
<TabItem value="ts" label="TypeScript"> | |
```ts title="vite.config.ts" | |
import { defineConfig } from 'vite' | |
import react from '@vitejs/plugin-react-swc' | |
import { devtoolsJson } from 'vite-plugin-devtools-json' | |
export default defineConfig({ | |
plugins: [ | |
react(), | |
devtoolsJson({ root: __dirname }) | |
] | |
}) | |
``` | |
</TabItem> | |
</Tabs> | |
```ts title="vite.config.ts" auto-js | |
import { defineConfig } from 'vite' | |
import devtoolsJson from 'vite-plugin-devtools-json' | |
export default defineConfig({ | |
plugins: [ | |
devtoolsJson({ root: import.meta.dirname }) | |
] | |
}) | |
``` |
</TabItem> | ||
</Tabs> | ||
|
||
3. Start your app with `wasp start`, open Chrome DevTools → **Sources › Filesystems** and you should see your project automatically mapped. Changes you make in DevTools now save to disk and Vite’s HMR updates the browser instantly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's make formatting consistent
- The folders are in Sources -> Workspace
3. Start your app with `wasp start`, open Chrome DevTools → **Sources › Filesystems** and you should see your project automatically mapped. Changes you make in DevTools now save to disk and Vite’s HMR updates the browser instantly. | |
3. Start your app with `wasp start`, open **Chrome DevTools → Sources → Workspace** and you should see your project automatically mapped. Changes you make in DevTools now save to disk and Vite's HMR updates the browser instantly. |
1. Install the plugin as a **dev-dependency**: | ||
|
||
```bash | ||
npm add -D vite-plugin-devtools-json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using npm
, this command is usually done with i
or install
instead of add
. And everywhere else in our docs we use i
, so let's change it.
npm add -D vite-plugin-devtools-json | |
npm i -D vite-plugin-devtools-json |
3. Start your app with `wasp start`, open Chrome DevTools → **Sources › Filesystems** and you should see your project automatically mapped. Changes you make in DevTools now save to disk and Vite’s HMR updates the browser instantly. | ||
|
||
:::tip Path normalisation | ||
The latest version of `vite-plugin-devtools-json` includes Windows, WSL and Docker-desktop path fixes contributed by the Wasp community – make sure you are on ≥ 0.4.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick
The latest version of `vite-plugin-devtools-json` includes Windows, WSL and Docker-desktop path fixes contributed by the Wasp community – make sure you are on ≥ 0.4.0. | |
The latest version of `vite-plugin-devtools-json` includes Windows, WSL and Docker Desktop path fixes contributed by the Wasp community – make sure you are on version 0.4.0 or greater. |
@cprecioso will be resolved asap!! |
Hey @0xTaneja are you still on this or should we pick it up from our end? 😊 |
well @cprecioso will take this by this week as was ill , that's why delayed |
Oh perfect! Didn't mean to rush! I hope you feel better :) |
Description
Referred from #2925
Select what type of change this PR introduces:
This PR adds a new section to the docs that shows Wasp users how to opt-in to Chrome DevTools Automatic Workspace mapping in development, without changing Wasp’s default setup.
Location:
web/docs/project/custom-vite-config.md
Section heading: “Chrome DevTools automatic workspace mapping”.
No generator templates or runtime code are touched—this is documentation-only, keeping the default Wasp bundle lean while giving power users an opt-in workflow.