Demonstration of debugging in a SPFx WebPart
git clone the repo
npm i
npm i -g gulp
gulp serve
- Debug using browser. Add the "debugger;" statement where you want the Web Browser debug to stop
debugger;
-
Install "Debugger for Chrome" extension, in Visual Studio Code
-
Run the Chrome app, with the necessary parameters to enable the debug options:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
- Add new debug configuration in Visual Studio Code (only for Chrome browser):
{
"name": "Launch localhost with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "https://localhost:4321/temp/workbench.html",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///../../../../*": "${webRoot}/*"
}
}