R
R
Rasul Gitinov2019-01-12 16:31:40
JavaScript
Rasul Gitinov, 2019-01-12 16:31:40

Why doesn't the "clean" task run during build?

Updated to version 4 of Gulp and began to fix the errors that began to appear.
During the build of the project, an error occurs:
5c39ebcca17b4190867808.png
To clean up the dist folder, I use the del plugin. Here are the task codes:

// Clean Dist

gulp.task('clean', function() {
  return del.sync('dist');
});

// Build project

gulp.task('build', gulp.parallel('clean', 'nunjucks', 'sass', 'scripts', 'css-libs', 'img'), function() {
  var buildHtml = gulp.src('app/*.html')
  .pipe(gulp.dest('dist'));

  var buildCss = gulp.src([
    'app/css/styles.css',
    'app/css/libs.min.css'
    ])
  .pipe(gulp.dest('dist/css'))

  var buildJs = gulp.src([
    'app/js/common.js',
    'app/js/libs.min.js'
  ])
  .pipe(gulp.dest('dist/js'))

  var buildFonts = gulp.src('app/fonts/**/*')
  .pipe(gulp.dest('dist/fonts'))
});

What could be the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey delphinpro, 2019-01-12
@raselgit

just call the callback, indicating that the task is completed.

gulp.task('build', gulp.parallel('clean', 'nunjucks', 'sass', 'scripts', 'css-libs', 'img'), function(cb) {
  var buildHtml = gulp.src('app/*.html')
  .pipe(gulp.dest('dist'))
  .on('end', function(){
    cb();// сигналим о завершении
  })

gulp.task('clean', function(cb) {
  del('dist').then( (paths) => {
    cb(); // сигналим о завершении
  }); 
});

Cleanup does not need to run in parallel with other tasks. First clear, then create. those.
gulp.series(
  'clean',
   gulp.parallel(все остальное)
)

D
Dima Polos, 2019-01-12
@dimovich85

Material

P
Pipop, 2019-01-14
@Pipop

There was the same error. Crutch method:

var paths = {
  dirs: {
    build: '.build'
  }
};

gulp.task('clean', function (cb) {
  del(paths.dirs.build);
  cb();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question