daiyue
daiyue

Reputation: 7448

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.

Upvotes: 1

Views: 115

Answers (1)

Vahid
Vahid

Reputation: 7551

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) {})

Upvotes: 4

Related Questions