From this StackOverflow post, I learned that it is generally not a good idea not to return anything in a gulp task. I want the caller to wait for the asynchronous tasks.
This is what my gulpfile.js
looks like currently:
'use strict';
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
livereload = require('gulp-livereload'),
del = require('del'),
util = require('gulp-util'),
paths = {
scripts: {
main: 'app.js',
controllers: 'controllers/*.js',
services: 'services/*.js'
},
css: 'css/*.css',
html: {
index: 'index.html',
views: 'views/*.html',
directives: 'directives/*.html'
},
bower_components: 'bower_components/*.*'
};
gulp.task('build-js', function() {
var destination;
for (var key in paths.scripts) {
util.log('Building ' + key);
if (/\*\.js$/.test(paths.scripts[key])) { // just so I catch app.js correctly in the paths
destination = 'build/' + paths.scripts[key].slice(0, -4);
} else {
destination = 'build/';
}
gulp.src(paths.scripts[key])
.pipe(uglify())
.pipe(gulp.dest(destination));
}
util.log('returning..');
return;
});
I am not sure what should I be returning in my build-js
task.
What is the best practice to do this? I do not want to install another module to resolve this.
Can anyone please point me in the right direction?