I upgraded from Gulp 3.9.1 to Gulp. 4.0.1 and now when I run it I see "Starting 'default'..."
and nothing else happens. Here's the end of my gulpfile:
gulp.task('default', function() {
gulp.watch('app/styles/**/*.scss', gulp.series('sass')),
gulp.watch('app/*.html', gulp.series('browserSync')),
gulp.watch('app/js/**/*.js', gulp.series('browserSync'));
return
});
// Optimization Tasks
// ------------------
// Optimizing CSS and JavaScript
gulp.task('useref', function() {
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpIf('*.js', uglify()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('dist'));
});
// Optimizing Images
gulp.task('images', function() {
return gulp.src('app/images/**/*.+(png|jpg|jpeg|gif|svg)')
// Caching images that ran through imagemin
.pipe(cache(imagemin({
interlaced: true,
})))
.pipe(gulp.dest('dist/images'))
});
// Copying fonts
gulp.task('fonts', function() {
return gulp.src('app/fonts/**/*')
.pipe(gulp.dest('dist/fonts'))
})
// Cleaning
gulp.task('clean', function() {
return del.sync('dist').then(function(cb) {
return cache.clearAll(cb);
});
})
gulp.task('clean:dist', function() {
return del.sync(['dist/**/*', '!dist/images', '!dist/images/**/*']);
});
// Build Sequences
// ---------------
gulp.task('build', function(callback) {
runSequence(
'clean:dist',
'sass',
['useref', 'images', 'fonts'],
callback
)
})
I've tried rewriting my code a few different ways and I've gotten various errors. The furthest I've gotten is with passing done
into functions and running the done
function at the end of some gulp tasks, but I understand that I should be able to use Gulp 4 without taking that route.