VSCode、运行 多项 Gulp 任务

VSCode, running multiple Gulp tasks

晚上,我在 VSCode 中遇到 运行 多个 Gulp 任务的问题,其中只有第一个任务是 运行,第二个只是被忽略了。当我 'Ctrl-Shift-B' 时,这两个任务单独工作,但在一起时,nada。

两个非常简单的命令,一个将我的 Typescript 构建到 JS 中,另一个只是缩小和连接。只是普通的东西。

这是我的 gulpfile.js

var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ts = require('gulp-typescript');

//  Task that is used to compile the Typescript in JS 
gulp.task('typescriptCompilation', function () {
  return gulp.src('scripts/*.ts')
    .pipe(ts({
        noImplicitAny: true,
        out: 'output.js'
    }))
    .pipe(gulp.dest('scripts')); 
});

//  Task that is used to minify anf concatanate the JS into one file for distribution
gulp.task('minifyAndConcat', function() {
  return gulp.src('scripts/*.js') // read all of the files that are in script/lib with a .js extension
    .pipe(concat('all.min.js')) // run uglify (for minification) on 'all.min.js'
    .pipe(uglify({mangle: false})) // run uglify (for minification) on 'all.min.js'
    .pipe(gulp.dest('dist/js')); // write all.min.js to the dist/js file
});

tasks.json

{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [],
"tasks": [
    {
        "taskName": "typescriptCompilation",
        "isBuildCommand": true,
        "showOutput": "always"
    },
    {
        "taskName": "minifyAndConcat",
        "isBuildCommand": true,
        "showOutput": "always"
    }
]
}

这很可能是我错过的一些简单的东西,但我是 Gulp 的新手,我看不到它......

您为什么不尝试再创建一项 gulp 任务:

gulp.task('default', ['typescriptCompilation', 'minifyAndConcat']);

然后在你的 tasks.json 中:

{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [],
"tasks": [
    {
        "taskName": "default",
        "isBuildCommand": true,
        "showOutput": "always"
    }
  ]
}