After reading a helpful post on StackOverflow about gulp tasks (viewable here), I came to the conclusion that it's not advisable to omit returning anything in a gulp task. For proper synchronization of asynchronous tasks, the caller should wait.
Presently, my gulpfile.js
appears as follows:
'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])) {
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 uncertain about what should be returned within my build-js
task.
What is considered the best practice in this scenario? Installing an additional module to address this issue isn't something I wish to do.
Any guidance on how to proceed would be greatly appreciated!