VSCODE V0.7.0 TASKS SHORTCUTS
Gulp, Grunt and Jake are autodetected only if the corresponding files are present in the root of the opened folder. With the Gulp tasks below, the sub-tasks optimize
for serve-build
, and inject
for serve-dev
, run additional sub-task and so forth and so on... This process makes two top-level tasks available for build and dev workflows.
gulpfile.js
//automate build node server start and restart on changes
gulp.task('serve-build', ['optimize'], function () {
serve(false /* is Build */);
});
//automate dev node server start and restart on changes
gulp.task('serve-dev', ['inject'], function () {
serve(true /* is Dev */);
});
The above Gulp tasks will be autodetected by VSCode as will many others.
However, you can manually define two keyboard shortcut tasks for TEST
and BUILD
in your tasks.json file. Subsequently, you can run TWO
top-level tasks with CTRL-SHFT-T
and CTRL-SHFT-B
respectively.
tasks.json
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "serve-dev",
"isBuildCommand": false,
"isTestCommand": true,
"showOutput": "always",
"args": []
},
{
"taskName": "serve-build",
"isBuildCommand": false,
"isTestCommand": true,
"showOutput": "always",
"args": []
}
Notice the two properties isTestCommand
and isBuildCommand
. These directly map to CTRL-SHFT-T
and CTRL-SHFT-B
. So you can map any task to these keyboard shortcuts depending on your needs. If you have more than one task with these properties set to true
VSCode will use the first task in the tasks.json file.
With tasks structured and nested properly you should be able to build your workflows with two keyboard shortcuts and avoid having VSCode enumerate your tasks each time via the CTRL+SHFT+P menus.
suppressTaskname
There's a global property suppressTaskName
that can be used in the tasks.json. This property controls whether the task name is added as an argument to the command.
I'm not sure if this can help but it's good to know about. It looks like this a way to pass built-in arguments to the task runner. More here Task Appendix. I haven't had a chance to test this to determine how if differs from the traditional "args:[]"
property. I know that prior to v0.7.0 there were problems with args
that when is was used the arguments and tasknames had to be reversed. See accept args the task name and args had to be reversed
The showOutput
property can also be useful with and without the with problemMatcher
property for display output in the VSCode Output window.
{
"version": "0.1.0",
"command": "gulp",
"showOutput": "silent"
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "gulp-argument",
"suppressTaskName": true,
...
},
{
"taskName": "test",
"args": [],
"isBuildCommand": true,
"showOutput": "always",
"problemMatcher": "$msCompile"
...
},
{
}....
]
}
Following are a couple of other StackOverFlow theads on VSCode tasks:
Define multiple tasks in VSCode
Configure VSCode to execute different task
links