#
Using PluginsGulp plugins are Node Transform Streams that encapsulate common behavior to transform files in a pipeline - often placed between src()
and dest()
using the .pipe()
method. They can change the filename, metadata, or contents of every file that passes through the stream.
Plugins from npm - using the "gulpplugin" and "gulpfriendly" keywords - can be browsed and searched on the plugin search page.
Each plugin should only do a small amount of work, so you can connect them like building blocks. You may need to combine a bunch of them to get the desired result.
#
Do you need a plugin?Not everything in gulp should use plugins. They are a quick way to get started, but many operations are improved by using a module or library instead.
Plugins should always transform files. Use a (non-plugin) Node module or library for any other operations.
#
Conditional pluginsSince plugin operations shouldn't be file-type-aware, you may need a plugin like gulp-if to transform subsets of files.
#
Inline pluginsInline plugins are one-off Transform Streams you define inside your gulpfile by writing the desired behavior.
There are two situations where creating an inline plugin is helpful:
- Instead of creating and maintaining your own plugin.
- Instead of forking a plugin that exists to add a feature you want.