I
I
imko2021-08-25 12:16:46
JavaScript
imko, 2021-08-25 12:16:46

What is the difference between gulp.src() and vinyl-source-stream + vinyl-buffer?

In Gulp, you need conditional processing, for example, if there is a 'min' argument, then skip styles through CSSO, if not, then process further. I use ternary operators because I don’t want to hang more plugins like gulp-if, so I need a plug function to do this, I
.pipe(argv.min ? csso() : затычка())

see two plug options and both work if the stream already exists


  • function затычка() {
      return gulp.src('neverUsedName', {
        allowEmpty: true
      })
    }



  • import buffer from 'vinyl-buffer'
    import source from 'vinyl-source-stream'
    function затычка() {
      return source('fake-name')
        .pipe(buffer())
    }




However, when I want to do another task
function example() {
  // какие то действия
  return затычка()
}

then in the first case everything is fine, but in the second it swears Did you forget to signal async completion?
I don’t want to use the first way, it’s ugly) The
question is what is the difference between the streams that return gags and what options are there to use the second one?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question