Native solution in VScode using parallel tasks:
Ejecute it directly from the task manager F1 -> Task: Run Task
-> Development
and it will run both tasks in two separated shells in parallel using your scripts.
package.json
"scripts": {
"start-watch": "nodemon run-babel index.js",
"wp-server": "webpack-dev-server",
}
.vscode\tasks.json
See the line with the following: "dependsOrder": "parallel"
Note: works in vscode in windows and linux
{
"version": "2.0.0",
"tasks": [
{
"label": "start-watch in package.json",
"type": "npm",
"script": "start-watch",
"presentation": {
"clear": true,
"reveal": "silent",
"showReuseMessage": true
}
},
{
"label": "wp-server in package.json",
"type": "npm",
"script": "wp-server",
"presentation": {
"clear": true,
"reveal": "silent",
"showReuseMessage": false
}
},
{
"label": "Development",
"dependsOrder": "parallel",
"dependsOn": ["start-watch in package.json", "wp-server in package.json"]
},
{
"label": "Terminate All Tasks",
"type": "shell",
"command": "echo ${input:terminate}",
"problemMatcher": []
},
]
}
The only problem here is that unlike concurrently
which runs the commands in the same shell where you run the concurrently command and you can kill both processes (ctrl+C) at the same time, with task they run in two different shells inside the VSCode terminal and can only be terminated separately or we could define another task that will terminate all the open tasks (see the task called Terminate All Task
)
&&
will run your scripts sequentially while&
will run them in parallel.npm run start-watch & npm run wp-server
. This will run the first command as a background thread. This works really well when one of the commands is not long running and does not need to be manually exited later. Something likeconcurrently
allows you to kill all the threads at the same time with CTRL-C.