We will do something different here and have a recipe for each gulp-*
plugin that simply wraps around an existing NodeJS library.
There are ```gulp-*`` plugins that are
- well-written
- well-maintained
- fills up a void in the gulp ecosystem
- actually add something of value
Meanwhile, there are some that can simply be replaced with a gulp recipe, with the help of some utility libraries to glue them together.
Unfortunately, these plugins come with additional overhead: an extra GitHub repository, npm module, maintainer, tests, semantics, etc. It's much simpler in this case to use the original module directly where you can, which is what vinyl-source-stream handles for you.
(wip)
Sometimes this boil downs to a matter perspective, personal preference and what you are willing (or unwilling) to sacrifice
For reasons why existing NodeJS libraries should be embraced over thin wrapper plugins, read the following articles for some insight:
- Why you shouldn’t create a gulp plugin (or, how to stop worrying and learn to love existing node packages)
- gulp + browserify, the gulp-y way
Of course, this is just an opinion on the subject.
(wip)
Sometimes, what you need is just a little utility or two to cook up your perfect gulp recipe.
- vinyl-transform: Great for libraries that work on a
filename
and returns a ReadableStream (e.g:browserify
) - vinyl-map: Perfect for libraries that work on a
filename
and/or itsbuffer
content and returns a string output (e.g:clean-css
) - vinyl-source-stream: Just the thing you need to convert a regular NodeJS ReadableStream to a gulp stream that emits streaming
vinyl
file objects - vinyl-buffer: Usually paired with
vinyl-source-stream
, this library converts your streaming vinyl file objects (which you get fromvinyl-source-stream
) to a buffered form (which most gulp pipes usually work on) - gulp-concat: Need to concatenate a bunch of input files into a single output file? This is the tool for you.
Wrapper plugin | Original library | Gulp recipe | Glue(s) | Note(s) |
---|---|---|---|---|
gulp-browserify | browserify | browserify.js | vinyl-transform | - |
gulp-minify-css | clean-css | clean-css.js | vinyl-map | - |
gulp-clean-css | clean-css | clean-css.js | vinyl-map | - |
gulp-cleancss | clean-css | clean-css.js | vinyl-map | - |
gulp-cssmin | clean-css | clean-css.js | vinyl-map | - |
gulp-uglify | uglify-js | uglify-js.js | vinyl-map & gulp-concat | - |
gulp-rimraf | rimraf | del.js | none | rimraf does not support glob patterns; use del instead. Credits: delete-files-folder |
gulp-clean | rimraf | del.js | none | rimraf does not support glob patterns; use del instead. Credits: delete-files-folder |