Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run multiple vscode tasks simultaneously?

For example, running a typescript watch task & a gulp task at the same time. (Without using the terminal)

like image 313
Alex Avatar asked Mar 21 '17 09:03

Alex


People also ask

How do I run multiple codes in Visual Studio?

Launch VS Code and press the “Ctrl” and “P” keys simultaneously to search for a file to open in the current project. Type in the file name. To open the new file in a temporary tab, click on it once. To open the new file in a separate window that you can choose to close manually, double-click it.

How do you highlight all occurrences in Vscode?

Ctrl + Shift + L to select all occurrences of current selection. Save this answer.


2 Answers

I use a tasks.json like this to run two watch tasks simultaneously:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Watch all",
            "dependsOn": [
                "Watch package 'core'",
                "Watch package 'ui'"
            ],
            "dependsOrder": "parallel",
            "group": "build",
            "problemMatcher": [
                "$tsc-watch"
            ],
            "isBackground": true
        },
        {
            "label": "Watch package 'core'",
            "type": "typescript",
            "tsconfig": "packages/core/tsconfig.json",
            "option": "watch",
            "problemMatcher": [
                "$tsc-watch"
            ],
            "group": "build"
        },
        {
            "label": "Watch package 'ui'",
            "type": "typescript",
            "tsconfig": "packages/ui/tsconfig.json",
            "option": "watch",
            "problemMatcher": [
                "$tsc-watch"
            ],
            "group": "build"
        }
    ]
}

When you open the build menu in vscode then you can choose to run the two separate watch tasks or the "Watch all" task which runs the other two tasks.

I guess you can easily replace one of the watch tasks with your gulp task.

like image 71
kayahr Avatar answered Sep 27 '22 18:09

kayahr


See running multiple tasks. You can use the "dependsOn" key in a version 2.0.0 tasks.json. Example from above link:

{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "Client Build",
            "command": "gulp",
            "args": ["build"],
            "isShellCommand": true,
            "options": {
                "cwd": "${workspaceRoot}/client"
            }
        },
        {
            "taskName": "Server Build",
            "command": "gulp",
            "args": ["build"],
            "isShellCommand": true,
            "options": {
                "cwd": "${workspaceRoot}/server"
            }
        },
        {
            "taskName": "Build",
            "dependsOn": ["Client Build", "Server Build"]
        }
    ]
}

Apparently, this is still preliminary? and so difficult to find documentation unless I am just missing it. But I tested it and it works. It was added in vscode 1.10.

like image 30
Mark Avatar answered Sep 27 '22 18:09

Mark