vscode-vite
vscode-vite copied to clipboard
How do you use this extension to debug a vite app?
I cannot see how to break on breakpoints in the components code ? Is it possible with this extension ? Is there some configuration to add to vscode ?
I've been trying to figure this out as well. Based on looking into the vscode-browse-lite that this extension depends on, I tried adding a configuration in launch.json
that uses:
{
"type": "browse-lite",
"name": "Browse Lite: Attach",
"request": "attach",
"port": 9222
}
but it gives me the error:
Couldn't find a debug adapter descriptor for debug type 'chrome' (extension might have failed to activate).
I'm wondering if the values here need to be updated to "pwa-chrome" instead of "chrome". This is just a wild guess, I really don't know much about this.
In reality, you don't need this extension to perform debugging in VSCode. I used a Vite+React+Yarn project VSCode debugging is an annoying 3 step process. I wish there was just one button press after setting the break-point.
First save the launch.json
file with the following:
{ "type": "pwa-chrome", "request": "launch", "name": "open chrome debug", "url": "http://localhost:3000" }
- From the command line, run
yarn dev
- Place a break-point somewhere in your code.
- Within VSCode, press the green arrow start debugging button or press F5 on the keyboard
That launch.json config will open a new Chrome window (outside of VS Code), correct? I think the intention of this issue is to figure out how to attach the debugger to the embedded browser that this plugin opens within VS Code. The benefit being that you can interact with the app within the embedded browser to trigger breakpoints, etc.
yes, that will open a new external chrome browser window outside of VS Code.
When you run your Vite project by command line, npm start
or yarn dev
, the Vite project will default to localhost:3000
Having set the url to localhost:3000
within the launch.json
file, the VS Code debugger will auto-attach itself.
I think we're talking about two different things 😄
The process you're describing is a way to attach a VS Code debugger to an external Chrome window, which is unrelated to this plugin.
But the question is, how do we attach the VS Code debugger to the embedded Chrome window that this plugin opens within a VS Code panel? That's a separate situation and requires a different launch.json
config. My first comment covers my attempt to get that to work, but I haven't been successful.
(To be clear, the process you described is a great approach if you don't care about using this plugin. It's what I'm currently doing, too. But I'm still curious whether it's possible to attach the VS Code debugger to the embedded browser this plugin opens.)
I also couldn't attach the VS Code debugger to the embedded window.
I think only the developer of the plugin will know how to properly configure the launch.json
file.
@antfu this might be very easy to answer for you!
I wasn't satisfied with the debugging-experience of the MS Edge Devtools Extension and came to vscode-vite to find a better experience. I'm sure this is possible, but I don't know how to configure my launch.json
to do the right thing!
I'm getting the same error as @genericGenie:
Couldn't find a debug adapter descriptor for debug type 'chrome' (extension might have failed to activate).
with this as my launch.json
(default-generated of browse-lite
-extension):
{
"version": "0.2.0",
"configurations": [
{
"type": "browse-lite",
"name": "Browse Lite: Attach",
"request": "attach"
},
{
"type": "browse-lite",
"request": "launch",
"name": "Browse Lite: Launch",
"url": "http://localhost:4000"
}
]
}
I've tested it with:
~
λ code --version
1.71.2
74b1f979648cc44d385a2286793c226e611f59e7
x64
~
λ code-insiders --version
1.72.0-insider
ba515cdbb48470c116884deb6de17981d341ec06
x64
Same here. Please @antfu, any suggestions on which launch.js to use?