在Vscode中debug Angular library

·  阅读 69

Debug Angular Library in Vscode

  1. 在angular.json中配置sourceMap:

     "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "crp-ui:build",
            "sourceMap": { // 添加这几项配置
              "scripts": true,
              "styles": true,
              "vendor": true
            }
          },
          //...
          }
    复制代码
  2. 配置launch.json

"configurations": [
   {
     "type": "chrome",
     "request": "launch",
     "name": "debug",
     "url": "http://localhost:4400",
     "webRoot": "${workspaceFolder}/projects",
     "sourceMapPathOverrides": {
       "webpack:///ng://citirisk-widgets/src/lib/*": "${workspaceFolder}/projects/citirisk-widgets/src/lib/*"
     },
     // 以下配置仅供参考,仅个人需要,以此备份
     "runtimeArgs": [
       "--disable-web-security"
     ],
     "runtimeExecutable": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
     "userDataDir": true,
   },
   // ... 
]
   
复制代码
分类:
前端
标签:
收藏成功!
已添加到「」, 点击更改