如何在angular中调试外部js文件

时间:2017-06-26 13:05:39

标签: angular visual-studio-code angular-cli webpack-2

不确定这是否是发布问题的正确位置(如果没有,请告诉我)。 我是Angular的新手,我想以某种方式使用“Debugger for chrome”或任何其他方式调试我项目中的一个外部js文件...

工具: visual studio code v1.13.1 节点v6.10.3 angular cli v10.0.6

launch.json

{
"version": "0.2.0",
"configurations": [

    {
        "type": "chrome",
        "request": "launch",
        "name": "Launch Chrome against localhost",
        "url": "http://localhost:4200/",
        "webRoot": "${workspaceRoot}",
        "sourceMaps": true
    },
    {
        "type": "chrome",
        "request": "attach",
        "name": "Attach to Chrome",
        "port": 9222,
        "sourceMaps": true,
        "webRoot": "${workspaceRoot}"
    }
]

角cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "debugging-test"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.css",
        "../node_modules/icheck/skins/square/aero.css",
        "styles.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/icheck/icheck.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

enter image description here

调试ts文件或我编写的任何代码都没有问题。

所需文件的所有代码都以单个字符串显示,我猜它是捆绑的,这就是我无法调试它的原因。

我正在放置断点,但是当调试器运行时,它们会变为灰色,并显示“断点被忽略,因为找不到生成的代码(源映射问题?)”

我有办法实现这一目标吗? (使用vs代码,或在chrome浏览器中无关紧要)

如有需要,我会提供所有其他信息。

提前致谢!

0 个答案:

没有答案