如何为 Chrome(或 Edge)扩展设置调试器以正确断点在 wwwroot 之外提供的源文件?
How to set up a debugger for a Chrome (or Edge) extension to properly breakpoint source files served outside of wwwroot?
我的项目是这样安排的:
${workspaceFolder}
/wwwroot
/res
/res 目录用于通过安全控制器提供文件。
我的问题是通过 "Debugger for Chrome"(或 Edge)扩展在 VS Code 中进行源代码调试。
如果我在 VS Code 的 JS 文件中放置一个断点,如果该文件存在于 wwwroot 目录下(它在源代码中的那个点停止),它将正常工作。
但是如果 js 文件是从 /res 目录(在网络浏览器中为 /res)提供的,VS Code 将打开该文件的一个新实例,而不是源实例。
我想我需要为调试器做某种目录映射以将 http://localhost/res 转换为 ${workspaceFolder}/res 以调试源文件,但我不确定正确的设置(可能需要设置 sourceMapPathOverrides,但我的尝试失败了。)。
我使用了错误的命令。 pathMapping 是我需要使用的。
下面的 launch.json 配置允许我断点位于 wwwroot 之外的源文件(在本例中为 /res)
{
"name": "Launch localhost in Microsoft Edge (Chromium) Canary",
"type": "edge",
"request": "launch",
"version": "canary",
"url": "http://127.0.0.1:5100/test.html",
"webRoot": "${workspaceFolder}/wwwroot",
"pathMapping": {
"/res": "${workspaceFolder}/res"
}
}
我的项目是这样安排的:
${workspaceFolder}
/wwwroot
/res
/res 目录用于通过安全控制器提供文件。
我的问题是通过 "Debugger for Chrome"(或 Edge)扩展在 VS Code 中进行源代码调试。
如果我在 VS Code 的 JS 文件中放置一个断点,如果该文件存在于 wwwroot 目录下(它在源代码中的那个点停止),它将正常工作。
但是如果 js 文件是从 /res 目录(在网络浏览器中为 /res)提供的,VS Code 将打开该文件的一个新实例,而不是源实例。
我想我需要为调试器做某种目录映射以将 http://localhost/res 转换为 ${workspaceFolder}/res 以调试源文件,但我不确定正确的设置(可能需要设置 sourceMapPathOverrides,但我的尝试失败了。)。
我使用了错误的命令。 pathMapping 是我需要使用的。
下面的 launch.json 配置允许我断点位于 wwwroot 之外的源文件(在本例中为 /res)
{
"name": "Launch localhost in Microsoft Edge (Chromium) Canary",
"type": "edge",
"request": "launch",
"version": "canary",
"url": "http://127.0.0.1:5100/test.html",
"webRoot": "${workspaceFolder}/wwwroot",
"pathMapping": {
"/res": "${workspaceFolder}/res"
}
}