我使用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"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当您在 vscode 中打开构建菜单时,您可以选择运行两个单独的监视任务或运行其他两个任务的“全部监视”任务。
我想你可以很容易地用你的 gulp 任务替换一个 watch 任务。
请参阅运行多个任务。您可以在 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"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
显然,这还是初步的?并且很难找到文档,除非我只是想念它。但我测试了它并且它有效。它是在 vscode 1.10 中添加的。
hxl*_*lnt -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 并搜索“任务:运行任务”来运行任务。
请参阅https://code.visualstudio.com/docs/editor/tasks上的更多文档。
| 归档时间: |
|
| 查看次数: |
5060 次 |
| 最近记录: |