例如,运行打字稿监视任务&同时执行一项任务。 (不使用终端)
答案 0 :(得分:1)
见running multiple tasks。您可以在版本2.0.0 tasks.json中使用“dependsOn”键。以上链接示例:
{
"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"]
}
]
}
显然,这还是初步的?除非我错过了它,否则很难找到文档。但我测试了它,它的工作原理。它被添加到vscode 1.10中。
答案 1 :(得分:1)
我使用tasks.json
来同时运行两个监视任务:
{
// 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"
}
]
}
在vscode中打开构建菜单时,您可以选择运行两个单独的监视任务,也可以选择运行其他两个任务的“监视所有”任务。
我想您可以用gulp任务轻松地替换其中一个watch任务。
答案 2 :(得分:-1)
VS Code有一个内置的任务运行器,您可以使用多个任务进行配置。
在VS Code中,键入Ctrl + Shift + P并搜索"任务:配置任务运行器。"将创建tasks.json
文件。这是一些示例代码,展示了如何配置多个任务。
{
"version": "0.1.0",
"tasks": [
{
"taskName": "tsc",
"command": "tsc",
"args": ["-w"],
"isShellCommand": true,
"isBackground": true,
"problemMatcher": "$tsc-watch"
},
{
"taskName": "build",
"command": "gulp",
"args": ["build"],
"isShellCommand": true
}
]
}
按Ctrl + Shift + P并搜索"任务:运行任务来运行任务。"