In the following snippet, what will be the input to and output of .pipe(gulpIf('*.css', cssnano()))
?
gulp.task('useref', function(){
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpIf('*.js', uglify()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('dist'))
});
API docs (link) says .pipe(destination)
returns a reference to the destination stream for setting up chain, if so .pipe(gulpIf('*.js', uglify()))
will return a stream to a minified .js file, how can it be piped to .pipe(gulpIf('*.css', cssnano()))
?
Gulp is just a task runner with a rather simple base functionality. Its power comes from the extensive ecosystem of third-party packages, of which your own snippet is using a minimum of four. And I say four because that's what shows up in your gulpfile.js source code; gulp itself has 13 direct runtime dependencies:
... and a similar number of direct development dependencies.
The streams that gulp passes around are provided by vinyl-fs and do not represent a single file but a virtual file-system.
As about your code, you definitively start only with HTML files:
... but right after that you execute a third-party package called gulp-useref:
As per its docs:
In other words, it parses the HTML file to identify/generate asset files and it gets them added to the stream for further processing.