SourceMap mapping webpack to wrong file location in VSCode Debug
OS: Windows 10 angular-cli: 1.0.0-beta.16 node: 6.7.0
When creating a new project using the angular-cli and attempting to debug, none of the breakpoints I am setting are being hit. After looking into the log file for the debugger I have found that webpack is mapping to the wrong source location. I have listed repro steps along with the location of a log file, my launch configurations and an example of what I am seeing when I say that webpack is mapping to the wrong location. I was hoping someone had some insight into why this is happening.
Repro steps:
- Download Debugger for Chrome in VS Code
- Create new project using angular-cli
- Set Launch.json configurations to launch in chrome with diagnosticLogging set to true
- Set breakpoints in typescript files and Launch the app
- Log file can be found at C:\Users{{your username}}.vscode\extensions\msjsdiag.debugger-for-chrome-0.5.2\vscode-chrome-debug.txt
Example from the log (entire log file attached): vscode-chrome-debug.txt
SourceMap: mapping webpack:///C:/Users/pderks/Desktop/test-app/src/app/app.component.ts => c:\Users\pderks\Desktop\test-app\C:\Users\pderks\Desktop\test-app\src\app\app.component.ts
**Notice that the path c:\Users\pderks\Desktop\test-app is appearing twice.
Launch configurations: { "version": "0.2.0", "configurations": [ { "name": "Launch Chrome against localhost, with sourcemaps", "type": "chrome", "request": "launch", "url": "http://localhost:4200", "diagnosticLogging": true, "sourceMaps": true, "webRoot": "${workspaceRoot}" } ] }
@andresbm05 's solution fixed it for me as well!
In my case, the configuration for launch was set right but my code still wasn't hitting the breakpoints. The intent was to add breakpoints on my VS to debug locally with my local angular project.
Simply ran 'ng build' before hitting 'npm run localhmr' on my angular project to get into debug mode. Hope this helps others in a similar situation.
To make breakpoints work in @angular/cli library projects, I had to configure the launch like this:
BTW, I use scoped packages: @SCOPED_PACKAGE_NAME/PROJECT_NAME
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///ng://@SCOPED_PACKAGE_NAME/PROJECT_NAME/lib/*": "${workspaceRoot}/projects/PROJECT_NAME/src/lib/*",
"webpack:///*": "${workspaceRoot}/*"
}
}
]
}
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.