首页 > 解决方案 > VSCode、Electron、TypeScript、调试渲染器进程、设置跳过文件?

问题描述

我已经开始在 VS Code 中使用 Typescript 创建一个 Electron 应用程序。经过大量重新配置后,除了渲染过程的跳过文件外,我已经能够进行调试。

如何配置调试器以跳过不是我的代码的代码文件?

这是我当前的 launch.json 文件。

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Electron: Main",
        "type": "node",
        "request": "launch",
        "program": "${workspaceRoot}\\src\\main.ts",
        "stopOnEntry": false,
        "args": [],
        "cwd": "${workspaceRoot}",
        "runtimeExecutable": "${workspaceRoot}\\node_modules\\.bin\\electron.cmd",
        "runtimeArgs": [
            "--no-lazy",
            "--remote-debugging-port=9223"
        ],
        "env": {},
        "console": "internalConsole",
        "sourceMaps": true,
        "outFiles": [
            "${workspaceFolder}/dist/**/*.js"
        ],
        "skipFiles": [
            // this explains the skipFiles tag
            // https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_skipping-uninteresting-code-node-chrome
            "${workspaceFolder}/node_modules/**/*.js",
            "${workspaceFolder}/lib/**/*.js",
            "<node_internals>/**/*.js"
          ]
    },
    {
        "name": "Electron: Renderer",
        "type": "chrome",
        "request": "attach",
        "port": 9223,
        "webRoot": "${workspaceFolder}",
        "timeout": 30000,
        "skipFiles": [
            // this explains the skipFiles tag
            // https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_skipping-uninteresting-code-node-chrome
            "${workspaceFolder}/node_modules/**/*.js",
            "${workspaceFolder}/lib/**/*.js",
            "<node_internals>/**/*.js"
          ]
    }
],
"compounds": [
    {
        "name": "Electron: All",
        "configurations": [
            "Electron: Main",
            "Electron: Renderer"
        ]
    }
]
}

skipFiles 适用于主进程,但在调试渲染器进程时我仍然会出现随机代码。任何建议,将不胜感激。

标签: typescriptdebuggingvisual-studio-codeelectron

解决方案


推荐阅读