-
This is only documentation about Debugging in VS Code for Vue CLI & webpack. Please adding the vite alternatives. Currtly, we only debug by console.log. which is very ugly. we don't know how to set break points and debug in code editor? |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 7 replies
-
Refer:https://github.com/vitejs/vite/blob/main/.github/contributing.md#repo-setup |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
@softboy99 please avoid sending multiple messages to an issue. I'll move this to a GitHub Discussion, and you can also join the chat at Vite Land to ask questions. You can also check this article, that will guide you through the process https://maximomussini.com/posts/debugging-javascript-libraries/ |
Beta Was this translation helpful? Give feedback.
-
Just starting with Vue3 and use vite as recommended in the Vue documentation. I like vite as it seems simple enough to get started with and it seems to just work. Btw the article listed above by @patak-js is just a generic how to debug with node. While any help is appreciated there is no mention of vscode, so it doesn't answer the question. |
Beta Was this translation helpful? Give feedback.
-
I got some success debugging a vite/vuejs 3 project with VS Code using Edge. Probably work with Chrome too. Click on Run and Debug then on the "create a lauch.json file" link. In the popup option list, choose Edge Launch. The content of that list may change depending of the current active file in the editor.
Change url setting to "http://localhost:3000" if you use default project url and port for your project. Save launch.json file. Next, run the project with
Second, click on the Run and Debug (Ctrl+Shift+D), then choose Lauch Edge. Edge should open to project url and vs code start to listen for debugging. Set a breakpoint in a vue component for example and it should be hit: The current line in the screnshoot is the next after the breakpoint because I hit F10 in vs code :) |
Beta Was this translation helpful? Give feedback.
-
Just to add some more zest to these answers, here's my current configuration which also includes launching the dev server and skipping files in {
"type": "pwa-chrome",
"request": "launch",
"skipFiles": ["${workspaceFolder}/node_modules/**/*.js"],
"name": "Debug app",
"preLaunchTask": "npm: start",
"url": "https://localhost:8080",
"webRoot": "${workspaceFolder}"
} This launch configuration assumes you have |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hmm, I thought my setup worked but breakpoints in some files stop at the right line while others don't. Files with vue/quasar components seem to have trouble while files with pure logic tends to stop at the intended line. (vue 3.2.23, typescript 4.4.3, vue-tsc 0.29.6, vite 2.6.14, @vitejs/plugin-vue 1.10.1, quasar 2.3.3, @quasar/vite-plugin 1.0.2, linux chrome) @softboy99 can you confirm whether in your case a debugger statement works and if not, what the behavior is? Update: |
Beta Was this translation helpful? Give feedback.
-
how to debug a vite plugin source code in vscode? |
Beta Was this translation helpful? Give feedback.
-
Got a successful configuration with python BE, node FE with typescript and vue, chrome, served with vite. Launch.json file below:
The npm run dev command is just a script in package.json file that defaults to 'vite serve' and the |
Beta Was this translation helpful? Give feedback.
-
Thanks @hspaay here a workaround I found whenever the React Component breakpoint is not working:
export const debugData = (...params) => {
console.log("debugData", params);
};
|
Beta Was this translation helpful? Give feedback.
-
How to debug in WebStorm? |
Beta Was this translation helpful? Give feedback.
-
As mentioned here, the key for me was updating "webRoot": "${workspaceFolder}/projects/ld/app", Update 1: If you are working in a monorepo and importing code from other packages containing you're code, you'll likely also need this: "pathMapping": {
"/@fs/": ""
},
Update 2: Ignore the previous paragraph. It's much easier to debug path mapping in VSCode with these resources. |
Beta Was this translation helpful? Give feedback.
-
This took me a while to discover, so I think it might also help someone else out there! If you're debugging a Vue 3 application using Vite and you can't hit breakpoints set in {
"preLaunchTask": "task: dev",
"name": "chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5173",
"enableContentValidation": false,
"webRoot": "${workspaceFolder}/src",
"pathMapping": {"url": "/src/", "path": "${webRoot}/"}
} |
Beta Was this translation helpful? Give feedback.
I got some success debugging a vite/vuejs 3 project with VS Code using Edge. Probably work with Chrome too.
Starting with no browser extension and no launch.json file in project.
Click on Run and Debug then on the "create a lauch.json file" link. In the popup option list, choose Edge Launch. The content of that list may change depending of the current active file in the editor.
Here is the content created: