如何使用键盘快捷键运行Gulp任务
我想通过使用内置功能来运行带有VS代码的默认Gulp任务.我的task.json如下:
I want to run the default Gulp task with VS code by using the inbuilt feature to do so. My tasks.json is as follows:
{
"version": "2.0.0",
"tasks": [
{
"type": "gulp",
"task": "default",
"problemMatcher": []
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"type": "gulp",
"task": "default",
"problemMatcher": []
}
]
}
当我使用键盘快捷键运行任务时(我的按键绑定已被修改以运行任务),我将获得一个包含所有Gulp任务列表的选项菜单.要实际运行gulp
命令,我必须从列表中选择'gulp:default'任务.如何在不查看列表并选择'gulp:default'选项的情况下运行任务?
When I run the task with the keyboard shortcut(my keybindings are already modified to run the task), I get an options menu with all the list of the Gulp tasks. To actually run the gulp
command, I have to select the 'gulp:default' task from the list. How can I run the task without having to see the list and selecting the 'gulp:default' option?
在workSpaceRoot的 .vscode/tasks.json 中:
In .vscode/tasks.json in the workSpaceRoot:
尝试以下操作-您需要的主要是使用标签"作为键绑定中的参数-标签可以是您想要的任何内容:
Try the following - the main thing you need is a "label" to use as an argument in your keybinding - the label can be whatever you want:
{
"version": "2.0.0",
"tasks": [
{
"label": "Your task label",
"command": "gulp",
"args": ["default"],
"type": "shell",
"options": {
"cwd": "${workspaceRoot}"
}
"problemMatcher": []
}
]
}
键盘绑定:
{ "key": "shift+escape",
"command": "workbench.action.tasks.runTask",
"args": "Your task label here"
},