G
G
Galdar Turin2019-01-06 00:27:16
JavaScript
Galdar Turin, 2019-01-06 00:27:16

How to move two files at once in one gulp request, to different folders?

I need to move two different files to different directories in one request, tell me how to do it.
First file:

return gulp.src('app/css/libs.css') // Выбор файла для сжатия
  .pipe(cssnano()) // Сжатие файла
  .pipe(rename({
    suffix: '.min'
  }))// Переименование файла с добавлением .min
  .pipe(gulp.dest('app/css/')),

Second file:
return gulp.src('app/crm/css/libs.css') // Выбор файла для сжатия
  .pipe(cssnano()) // Сжатие файла
  .pipe(rename({
    suffix: '.min'
  }))// Переименование файла с добавлением .min
  .pipe(gulp.dest('app/crm/css/'));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2019-01-06
@Galdar

Create one task, call gallp twice inside it.
You can just leave it like that.
If you need to signal the end of a task, then wrap the calls in promises, and use the Promise.all method to signal the end of all (in this case, two) processes.

gulp.task('mytask', function(done){
  let pipes = [];
  pipes.push(new Promise((resolve, reject) => {
    gulp.src(...)
      .pipe()
       …  
      .on('error', (err) => reject(err))
      .on('end', () => resolve())
  }));
  //... повторить нужное кол-во раз

  Promise.all(pipes).then((ok) => done(), (err) => done())
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question