Search code examples
javascriptgulp

Gulp does not copy files after clean


I tried the following code to clean the prod folder before copying files from scripts to it;

gulp.task('clean', async function () {
    del(['prod/*']);
});

gulp.task('minify', gulp.series('clean'), function (done) {
    gulp.src('scripts/*.js')
        .pipe(size())
        .pipe(minify(require('./minify.conf.js')))
        .pipe(size())
        .pipe(gulp.dest('prod'));

    done();
});

[email protected]

but after executing the above script, I got an empty prod folder (scripts is not empty), I am wondering how to fix it.


Solution

  • In gulp@4 or higher, the task method gets two arguments:

    /**
     * Register the task by the taskName.
     * @param taskName - Task name.
     * @param fn - Task function.
     */
    task(taskName: string, fn: Undertaker.TaskFunction): void;
    

    So your code should be:

    gulp.task('minify', gulp.series('clean', function (done) {})