Skip to content

Instantly share code, notes, and snippets.

@wtho
Last active May 19, 2018 20:57
Show Gist options
  • Save wtho/8a8924481763dc671c67b8868e54b695 to your computer and use it in GitHub Desktop.
Save wtho/8a8924481763dc671c67b8868e54b695 to your computer and use it in GitHub Desktop.
Configure launch.json in vscode for Webpack + TypeScript

How to setup Debugging with VSCode + Webpack + TypeScript

  1. Activate sourceMaps if running with TypeScript
  2. Make sure Chrome/Chromium runs with debugging on Port 9222 => Close Chrome and restart with the flag --remote-debugging-port=9222
  3. If in attach-mode, an url, or better: urlFilter is required: "urlFilter": "http://localhost:4200/*"
  4. Set the webRoot to your src folder: "webRoot": "${workspaceFolder}/src"
  5. To fix the source map matching, add sourceMapPathOverrides:
    "sourceMapPathOverrides": {
      "webpack:///src/*": "${webRoot}/*"
    }
    
  6. If not working immediately, use the "trace": "verbose"-option, reconnect the debugging and scroll up the console to the path matching, it will give debug logs on which parts are matched where to following the current override-rules.
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to chrome",
"port": 9222,
"urlFilter": "http://localhost:8080/*",
"address": "localhost",
"timeout": 1000,
"webRoot": "${workspaceFolder}/src",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*",
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment