clean.js 553 B

1234567891011121314151617181920212223
  1. const gulp = require('gulp');
  2. const plugins = require('gulp-load-plugins')();
  3. module.exports = config => {
  4. gulp.task('clean:main', () => {
  5. return gulp
  6. .src(config.buildDir, { read: false, allowEmpty: true })
  7. .pipe(plugins.clean({ force: true }));
  8. });
  9. gulp.task('clean:client', cb => {
  10. if (config.clientBuildDir) {
  11. return gulp
  12. .src(config.clientBuildDir, { read: false, allowEmpty: true })
  13. .pipe(plugins.clean({ force: true }));
  14. } else {
  15. cb();
  16. }
  17. });
  18. gulp.task('clean', gulp.parallel('clean:main', 'clean:client'));
  19. };