VSCode Custom Variables in Launch Settings?

Viewed 2396

Is there a way to add custom variables that I can use in my launch.json settings for debugging in VSCode? Currently, the only way I have found is to add them to my workspace settings and refer to the from the ${config} predefined variable.

I'd like to define variables/properties in the launch.json and use them. Here's an example of what that might look like if I wanted to add myCustomVar to all my URLs:

{
    "version": "0.2.0",
    "myCustomVar": "my_value",
    "configurations": [
        {
            "name": "Page 1",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost/page1.html?customVar=${myCustomVar}",
            "sourceMaps": true,
            "webRoot": "${workspaceFolder}/dev"
        },
        {
            "name": "Page 2",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost/page2.html?customVar=${myCustomVar}",
            "sourceMaps": true,
            "webRoot": "${workspaceFolder}/dev"
        }
}
1 Answers

Input variables might work?

Otherwise, you should be able to add custom settings to your VS Code settings.json file (it will warn you about "Unknown Configuration Setting") and insert them using ${config:myCustomVar}.

Related