Gulp: how to delete a folder?

your code should look like this:

gulp.task('clean', function(){
     return del('dist/**', {force:true});
});

according to the npm del docs "**" deletes all the subdirectories of dist (ps: don't delete dist folder):

"The glob pattern ** matches all children and the parent."

reference


According to the documentation : The glob pattern ** matches all children and the parent. You have to explicitly ignore the parent directories too

gulp.task('clean', function(){
     return del(['dist/**', '!dist'], {force:true});
});

More info available here : del documentation

Tags:

Gulp