本文介绍了未绑定断点 - VS Code |铬 |角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Angular 应用程序,我想在

但是,当我通过不同的配置提供服务时,例如ng serve -c qang serve -c uat 解除绑定:

断点未绑定是否有原因?使用不同的环境配置时,如何获得断点?


相关信息

launch.json 配置:

{版本":0.2.0",配置":[{类型":铬",请求":启动",名称":针对本地主机启动 Chrome",url":http://localhost:4200",webRoot":${workspaceFolder}"}]}

angular.json 示例环境配置:

uat":{文件替换":[{替换":src/environments/environment.ts",与":src/environments/environment.uat.ts";}],优化":真,outputHashing":所有",sourceMap":假,extractCss":真,namedChunks":假,extractLicenses":假,vendorChunk":假,buildOptimizer":真,预算":[{类型":初始",最大警告":2mb",最大误差":5mb"},{类型":anyComponentStyle",最大警告":6kb",最大错误":10kb"}]},

软件版本控制:

解决方案

解决这个问题很简单,我没有在 sourceMap 属性设置为 trueem>angular.json 对于那个特定环境,我有 "sourceMap": false,

参见 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap 了解更多信息.

感谢康纳 - https://github.com/microsoft/vscode-js-debug/issues/872

I have an Angular application that I am trying to debug in VS Code.

When I serve the application e.g. ng serve the breakpoints are bound and get hit:

However, when I serve via a different configuration e.g. ng serve -c qa or ng serve -c uat they become unbound:

Is there a reason why the breakpoints become unbound? How can I get the breakpoints to hit when serving with different environment configurations?


Relevant information

launch.json configuration:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

angular.json sample environment configuration:

"uat": {
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts",
      "with": "src/environments/environment.uat.ts"
    }
  ],
  "optimization": true,
  "outputHashing": "all",
  "sourceMap": false,
  "extractCss": true,
  "namedChunks": false,
  "extractLicenses": false,
  "vendorChunk": false,
  "buildOptimizer": true,
  "budgets": [
    {
      "type": "initial",
      "maximumWarning": "2mb",
      "maximumError": "5mb"
    },
    {
      "type": "anyComponentStyle",
      "maximumWarning": "6kb",
      "maximumError": "10kb"
    }
  ]
},

Software versioning:

解决方案

The fix for this was simple, I hadn't set the sourceMap property to true in angular.json for that particular environment, instead I had "sourceMap": false,

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap for more info.

With thanks to Connor - https://github.com/microsoft/vscode-js-debug/issues/872

这篇关于未绑定断点 - VS Code |铬 |角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 23:09