A ternary gulp plugin that conditionally controls the flow of vinyl objects in your build pipeline.
gulp-if is a Gulp plugin that acts as a conditional ternary operator for vinyl file streams. It allows developers to apply transformations or route files based on dynamic conditions within their Gulp build pipelines, enabling more intelligent and efficient build processes.
Developers using Gulp for build automation who need to apply transformations conditionally, such as minifying only production files or excluding specific files from certain processing steps.
It provides a clean, declarative way to handle conditional logic in Gulp streams without cluttering tasks with imperative if-else statements, and integrates seamlessly with other plugins and tools like lazypipe.
Conditionally run a task
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports booleans, functions, file stats, regular expressions, and glob patterns with minimatch options, enabling dynamic logic based on file properties or metadata.
Allows if-else logic within Gulp streams, routing files to different transformations (e.g., uglify or beautify) based on conditions, keeping pipelines declarative and clean.
Works well with lazypipe for creating reusable pipe chains, as shown in README examples where conditionally initialized steps like jshint or uglify are easily managed.
Enables early exclusion of files from streams using gulp-ignore or glob patterns, avoiding unnecessary processing and improving build speed, as highlighted in the 'Exclude things' example.
The README explicitly warns that badly behaved plugins can get worse with gulp-if, requiring fixes in those plugins rather than in gulp-if itself, which adds debugging overhead.
Tightly coupled with Gulp and its vinyl stream model, making it unsuitable for projects using alternative build tools or native Node.js streams without significant rework.
When used inside lazypipe, gulp-if must be wrapped in a function for proper instantiation, adding boilerplate and potential for errors, as noted in the README's advanced example.