-1

Evening, i've got an issue with running multiple Gulp tasks in VSCode, whereby only the first task is ever run, and the second is just ignored. Both tasks work individually when I 'Ctrl-Shift-B', but together, nada.

Two really simple commands, one that builds my Typescript into JS, the other to just minify and concatenate. Just regular stuff.

Here's my 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
});

And the tasks.json

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

It's most likely something simple i've missed, but i'm new to Gulp and I can't see it.....

Gama11
  • 31,714
  • 9
  • 78
  • 100
NewZeroRiot
  • 552
  • 1
  • 5
  • 22
  • may be because it runs the task in parallel.. can you try by using run-sequence. does that solves the issue? – harishr Dec 27 '15 at 13:55
  • Why not just create a new task that runs both? Or even add a dependency from "typescriptCompilation" to "minifyAndConcat". I'm not sure whether vscode runs multiple tasks or just the first one. – Louay Alakkad Dec 27 '15 at 20:22

1 Answers1

3

Why don't you try to create one more gulp task :

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

And then in your tasks.json :

{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [],
"tasks": [
    {
        "taskName": "default",
        "isBuildCommand": true,
        "showOutput": "always"
    }
  ]
}
Guillaume
  • 844
  • 7
  • 25
  • That's what I did in the end, i've left the tasks.json just for typescript compilation now. I'll mark this as the answer. Cheers anyway! – NewZeroRiot Dec 28 '15 at 10:59