Debugging config for renderer + main process
See original GitHub issueThere have been quite a number of issues opened here related to debug configs, however, few of the solutions proposed are updated nor optimal. It’s perhaps outside the scope of this repo and I don’t believe the author has an obligation to address this, but I still feel like this is a good forum to get this figured out.
The config I’m using to debug currently looks like this (full repo is here):
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron: Main",
"protocol": "inspector",
// Prelaunch task compiles main.ts for Electron & starts Angular dev server.
"preLaunchTask": "Build: All",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": ["--remote-debugging-port=9223", "--serve", "."],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
},
{
"name": "Electron: Renderer",
"type": "chrome",
"request": "attach",
"port": 9223,
"webRoot": "${workspaceFolder}",
"timeout": 30000,
"urlFilter": "http://localhost:4200/*",
// Source map overrides are copied from Angular CLI debugging recipe.
// See: https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
}
}
],
"compounds": [
{
"name": "Electron: All",
// The main process should be started before renderer to prevent timeout.
"configurations": ["Electron: Main", "Electron: Renderer"]
}
]
}
// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build: All",
"type": "shell",
"command": "npm run electron:serve-tsc && ng serve",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "typescript",
"source": "ts",
"applyTo": "closedDocuments",
"fileLocation": ["relative", "${cwd}"],
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": "^.*",
"endsPattern": "^.*Compiled successfully.*"
}
}
}
]
}
The issue I’m running into with the above config is that breakpoints aren’t hitting in the render process (VSCode is showing the error Breakpoint ignored because generated code not found (source map problem?)
). I can debug the main process just fine with the above config, which is awesome. The chrome debugger also seems to be attaching correctly (can see the outputs in the debug console).
Just adding debugger;
statements to the Angular code lets me debug in the chrome devtools in the Electron window, but it would be far far better to debug inside VSCode.
Any ideas on how to get the Chrome debugger working on the render process?? I’d be happy to open a PR once a working debugging conf is found (if the author is OK with that).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7
Top GitHub Comments
Thanks for you config. Thanks to you i can debug the main-process now. Would be awesome if we manage to get the debugger for the render process working.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.