Map a local file to a remote URL for debugging

352 views Asked by At

I have written a CLI app that helps me to deploy code from code.html to a specified URL address by clicking F5 (it's configured in launch.json thorugh Powershell extension)

That command deploys my code, then opens a Chromium instance with the target page on which the code starts to run.

I want to debug this code (it's simply JavaScript embedded in HTML) in my local code.html file (setting breakpoints etc).

To do that, I have configured the described task as a prelaunchTask and then added a configuration that attaches a debugger to my running Chromium when it's ready (See below).

Everything is super cool, the browser attaches fine, but I simply can't map my local code.html to a code file(s) automatically generated at the specified URL location, because my code is not running in the same page I wrote in, but it's embedded into a remote page, which is autogenerated, i.e. I only know the URL address where it runs.

Is there a way to map the code.html file to a remote URL, so I could debug that code while running?

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "attach",
            "name": "Attach to Chrome",
            "port": 1234,
            "urlFilter": "https://somewebsite.com*",
            "webRoot": "${workspaceFolder}",
            "preLaunchTask": "deployment"
        }
    ],
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "deployment",
            "type": "shell",
            "command": "C:\\Something.exe",
            "args": [ someargs ]
        }
    ]
}
0

There are 0 answers