3.0.0 • Published 5 years ago

gulp-ignore v3.0.0

Weekly downloads
42,543
License
MIT
Repository
github
Last release
5 years ago

gulp-ignore status

Include or exclude gulp files from the stream based on a condition

Usage

1: Exclude things from the stream

Exclude things from entering the stream

var uglify = require('gulp-uglify');

gulp.task('task', function() {
  gulp.src(['./**/*.js', '!./node_modules/**'])
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

Grab all JavaScript files that aren't in the node_modules folder, uglify them, and write them. This is fastest because nothing in node_modules ever leaves gulp.src()

2: Remove things from the stream

Remove from here on

var gulpIgnore = require('gulp-ignore');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');

var condition = './gulpfile.js';

gulp.task('task', function() {
  gulp.src('./**/*.js')
    .pipe(jshint())
    .pipe(gulpIgnore.exclude(condition))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

Run JSHint on everything, remove gulpfile from the stream, then uglify and write everything else.

3: Filter only matching things

Include from here on

var gulpIgnore = require('gulp-ignore');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');

var condition = './public/**.js';

gulp.task('task', function() {
  gulp.src('./**/*.js')
    .pipe(jshint())
    .pipe(gulpIgnore.include(condition))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

Run JSHint on everything, filter to include only files from in the public folder, then uglify and write them.

4: Conditionally filter content, include everything down-stream

Condition

var gulpif = require('gulp-if'); // This is gulp-if, not gulp-ignore
var uglify = require('gulp-uglify');

var condition = function(file) {
  // Only files whose contents match a pattern
  return /a pattern/g.test(String(file.contents));
};

gulp.task('task', function() {
  gulp.src('./src/*.js')
    .pipe(gulpif(condition, uglify()))
    .pipe(gulp.dest('./dist/'));
});

Only uglify the content if the condition is true, but send all the files to the dist folder.

API

exclude(condition , minimatchOptions)

Exclude files whose file.path matches, include everything else

include(condition , minimatchOptions)

Include files whose file.path matches, exclude everything else

condition

Type: boolean or stat object or function that takes in a vinyl file and returns a boolean or RegularExpression that works on the file.path

The condition parameter is any of the conditions supported by gulp-match. The file.path is passed into gulp-match.

If a function is given, then the function is passed a vinyl file. The function should return a boolean.

minimatchOptions

Optional, if it's a glob condition, these options are passed to https://github.com/isaacs/minimatch.

LICENSE

(MIT License)

Copyright (c) 2014 Richardson & Sons, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

adgile-devsblogdev-agnitio-clidas-buildgulp-essentials@infinitebrahmanuniverse/nolb-gulp-i@everything-registry/sub-chunk-1808plus.webclient.build@das.laboratory/gulp-plugin-interactive@bloombox/js-client@gig177/gulpjs-dpkgs@toktokhan-fe/hooksquantimodo-docsvelvet-gulpunderstrap-childunderstrap_emmevnjson-local-builderwerkint-gulp-task-bowerwebdev-toolkitweapp-gulp-servicewindwalker-fusiontmt-helios-ui-bootstrapperslush-static-siteslush-stencilslush-performanceslush-xfuseslush-velvetslush-vtex-initslush-webhookslush-cmsslush-fullstack-frameworkslush-gh-pagesslush-node-typescript2slush-an-scaffoldsmashersocotraspa-herostudy_gulprepocopresponsive-filenamestepez-static-websitetesla-gulpslice-clisetrobot-gulpsnp-gulp-tasksspoonx-toolsrentivo-waypoint-timbercgfx-build-tools@dietechniker/gulp-sass-dependency-trackerct-mapapps-gulp-js@docta/gulp-ignoredapple@dorfjungs/base-gulp-tasks1000-packages@arco-cli/generator@arco-materials/template-core@eoskunkworks/understrap@evlop/clidefcondefcon-event-logdefcon-pluginsdoomjsdj-gulp-tasks@egis/build-tools@jysd/gulp-static-build@literacyplanet/lambda_gulp_deploy@microfocus/ng-gulp@movinliao/mlb@penskemediacorp/larva@nodulus/logs@prowebtec/opexdkid-builderlifterlms-lib-tasksiw-laravel-elixir-webpack@salesforce-ux/design-system-compiler@toktokhan-fe/initnative-zipfe-gulpfjadgileenterprise-portalmill-gulp-templateminecraft-addon-toolchaineasywebstartestradeste-cli@rightscale/ui-build-toolsjul-commentsjul-designerjworklaravel-elixir-puglaravel-elixir6-useref@unumux/ui-framework@unumux/ux-build-toolsmcap-generator-ionicdthpm@videinfra/static-website-buildermetal-tools-soymetaljsfranky-core
3.0.0

5 years ago

2.0.2

7 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.1

9 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago