GithubHelp home page GithubHelp logo

kryndex / gulp-newer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tschaub/gulp-newer

0.0 2.0 0.0 44 KB

Pass through newer source files only

Home Page: https://npmjs.org/package/gulp-newer

JavaScript 100.00%

gulp-newer's Introduction

gulp-newer

A Gulp plugin for passing through only those source files that are newer than corresponding destination files.

Install

npm install gulp-newer --save-dev

Example

Using newer with 1:1 source:dest mappings

The default task in the example below sets up a watch that minifies images on changes. Piping the source files to newer before imagemin ensures that only those images that have changed are minified. The newer plugin is configured with the directory path for minified images.

var gulp = require('gulp');
var newer = require('gulp-newer');
var imagemin = require('gulp-imagemin');

var imgSrc = 'src/img/**';
var imgDest = 'build/img';

// Minify any new images
gulp.task('images', function() {

  // Add the newer pipe to pass through newer images only
  return gulp.src(imgSrc)
      .pipe(newer(imgDest))
      .pipe(imagemin())
      .pipe(gulp.dest(imgDest));

});

gulp.task('default', function() {
  gulp.watch(imgSrc, ['images']);
});

Using newer with many:1 source:dest mappings

Plugins like gulp-concat take many source files and generate a single destination file. In this case, the newer stream will pass through all source files if any one of them is newer than the destination file. The newer plugin is configured with the destination file path.

var gulp = require('gulp');
var newer = require('gulp-newer');
var concat = require('gulp-concat');

// Concatenate all if any are newer
gulp.task('concat', function() {

  // Add the newer pipe to pass through all sources if any are newer
  return gulp.src('lib/*.js')
      .pipe(newer('dist/all.js'))
      .pipe(concat('all.js'))
      .pipe(gulp.dest('dist'));

});

API

newer(dest)

  • dest - string Path to destination directory or file.

newer(options)

  • options.dest - string As above, required.
  • options.ext - string Source files will be matched to destination files with the provided extension (e.g. '.css').
  • options.map - function Map relative source paths to relative destination paths (e.g. function(relativePath) { return relativePath + '.bak'; })
  • options.extra - string or array An extra file, file glob, or list of extra files and/or globs, to check for updated time stamp(s). If any of these files are newer than the destination files, then all source files will be passed into the stream.

Create a transform stream that passes through files whose modification time is more recent than the corresponding destination file's modification time.

If dest is a directory path, the newer stream will check for files in the destination directory with the same relative path as source files. Source files that have been modified more recently than the resolved destination file will be passed through. If the dest directory or resolved destination file does not exist, all source files will be passed through.

If dest is a file path, the newer stream will pass through all files if any one of them has been modified more recently than the destination file. If the dest file does not exist, all source files will be passed through.

Current Status

gulp-newer's People

Contributors

tschaub avatar timmensch avatar karlvr avatar martinvd avatar mprencipe avatar pgilad avatar lddubeau avatar greenkeeper[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.