Skip to content

Instantly share code, notes, and snippets.

@moreirapontocom
Created September 11, 2021 17:55
Show Gist options
  • Save moreirapontocom/f46e7b6dd0f34c200543da8ad958e90d to your computer and use it in GitHub Desktop.
Save moreirapontocom/f46e7b6dd0f34c200543da8ad958e90d to your computer and use it in GitHub Desktop.
Debug React apps in VS Code with breakpoints
// Start the task first running npm start or CMD+Shift+B (run build task)
// To disable React auto-launch in the default browser, I added "BROWSER=none" into the npm start script.
// Then run the debug session with F5. It will launch Chrome and breakpoints will work
// launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
]
}
// tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"problemMatcher": [],
"label": "npm: start",
"detail": "react-scripts start",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment