0

I am just working on an older project but I would like to make use of Gulp 4. I am looking to convert this into a valid Gulp 4 file. Would someone be able to assist or point me in the right direction.

var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify'); // Converts jsx to js


gulp.task('browserify', function(){
    browserify('./src/js/main.js')
        .transform('reactify')
        .bundle()
        .pipe(source('main.js'))
        .pipe(gulp.dest('dist/js'));
});

gulp.task('copy', function(){
    gulp.src('src/index.html')
        .pipe(gulp.dest('dist'));
    gulp.src('src/css/*.*')
        .pipe(gulp.dest('dist/css'));
    gulp.src('src/js/vendors/*.*')
        .pipe(gulp.dest('dist/js'));
});

gulp.task('default', ['browserify', 'copy'], function(){
    return gulp.watch('src/**/*.*', ['browserify', 'copy']);
});

ERROR:

AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask] (/Users/shanna/Desktop/Bookstore/node_modules/undertaker/lib/set-task.js:10:3) 
Mark
  • 143,421
  • 24
  • 428
  • 436
Pianoc
  • 763
  • 1
  • 11
  • 32
  • What errors are you getting? – BlackICE Feb 21 '19 at 11:42
  • AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask] (/Users/shanna/Desktop/Bookstore/node_modules/undertaker/lib/set-task.js:10:3) – Pianoc Feb 21 '19 at 11:47

1 Answers1

1
gulp.task('default', gulp.series('browserify', 'copy', function(done){
    gulp.watch('src/**/*.*', gulp.series('browserify', 'copy'));
    done();
}));

You can't call tasks like this :

['browserify', 'copy']

in gulp4. Use gulp.series or gulp.parallel and gulp.task takes only two parameters now.

Mark
  • 143,421
  • 24
  • 428
  • 436