First, Install gulp
and del
to project directory locally
npm install --save-dev gulp del
Then add the clean
task to your gulpfile.js
var gulp = require('gulp');
var del = require('del');
gulp.task('default', function() {
});
// Task to delete target build folder
gulp.task('clean', function() {
return del(['public/**', '!public']);
});
gulp.task('default', ['clean']);
This task deletes all files in the public directory
The task in the code is added as a dependency for the 'default'
task so every time default
will run, clean
will run before it.
You can also call the clean
task manually by running the command:
gulp clean