According to the documentation, it is possible to launch a program before debugging:
To launch a task before the start of each debug session, set the
So, if it's still relevant, or if someone finds this thread with the same problem, I've just figured it out how it works:
In the tasks.json, you need to create a 'tasks' array - code hint will help you with that - which holds an array of objects. Inside an object, you can have the 'taskName' key-value pair.
Example:
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"args": ["run-script", "webpack"],
"showOutput": "always",
"tasks": [
{
"taskName": "runwebpack",
"suppressTaskName": true
}
]
}
In my case, I had to run the npm run-script webpack
command before running my project.
In the launch.json file, the "preLaunchTask": "runwebpack"
will work now.
Note: the suppressTaskName
is true in my example. Omitting it, or setting it to false will result in VS Code appending the taskName
after the command.
A more general approach would be something like this:
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"args": ["run-script"],
"showOutput": "always",
"tasks": [
{ "taskName": "webpack" }
]
}
With the latter example, you can extend the tasks
array with other scripts to be run also.
Hint for my usage: npm run-script fetches what to do from the package.json file's scripts
object.
Edit: this works with VS Code 1.3.1