All Projects → sindresorhus → Gulp Changed

sindresorhus / Gulp Changed

Licence: mit
Only pass through changed files

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Changed

gulp-purgecss
Gulp plugin for purgecss
Stars: ✭ 21 (-97.15%)
Mutual labels:  gulp-plugin
Gulp Inline Css
Inline linked css in an html file. Useful for emails.
Stars: ✭ 264 (-64.18%)
Mutual labels:  gulp-plugin
Gulp Pug
Gulp plugin for compiling Pug templates
Stars: ✭ 512 (-30.53%)
Mutual labels:  gulp-plugin
anyfs
Portable file system for Node
Stars: ✭ 17 (-97.69%)
Mutual labels:  gulp-plugin
gulp-markdown-to-json
Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
Stars: ✭ 76 (-89.69%)
Mutual labels:  gulp-plugin
Gulp Filter
Filter files in a `vinyl` stream
Stars: ✭ 308 (-58.21%)
Mutual labels:  gulp-plugin
gulp-iife
A Gulp plugin for wrapping JavaScript code in IIFEs.
Stars: ✭ 39 (-94.71%)
Mutual labels:  gulp-plugin
Gulp Autoprefixer
Prefix CSS
Stars: ✭ 676 (-8.28%)
Mutual labels:  gulp-plugin
Gulp Zip
ZIP compress files
Stars: ✭ 262 (-64.45%)
Mutual labels:  gulp-plugin
Gulp Ruby Sass
Compile Sass to CSS with Ruby Sass
Stars: ✭ 476 (-35.41%)
Mutual labels:  gulp-plugin
gulp-yarn
Automatically install node modules using Yarn. 😻
Stars: ✭ 22 (-97.01%)
Mutual labels:  gulp-plugin
gulp-yaml
A Gulp plugin to convert YAML to JSON
Stars: ✭ 24 (-96.74%)
Mutual labels:  gulp-plugin
Gulp Mocha
Run Mocha tests
Stars: ✭ 374 (-49.25%)
Mutual labels:  gulp-plugin
gulp-golang
gulp plugin for golang projects
Stars: ✭ 13 (-98.24%)
Mutual labels:  gulp-plugin
Gulp Angular Templatecache
Concatenates and registers AngularJS templates in the $templateCache.
Stars: ✭ 530 (-28.09%)
Mutual labels:  gulp-plugin
gulp-micro
Ensure your micro-lib stays micro
Stars: ✭ 15 (-97.96%)
Mutual labels:  gulp-plugin
Gulp Template
Render/precompile Lodash templates
Stars: ✭ 276 (-62.55%)
Mutual labels:  gulp-plugin
Gulp Useref
Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
Stars: ✭ 720 (-2.31%)
Mutual labels:  gulp-plugin
Gulp Gh Pages
A gulp 4 plugin to publish contents to Github pages
Stars: ✭ 611 (-17.1%)
Mutual labels:  gulp-plugin
Gulp Shell
A handy command line interface for gulp
Stars: ✭ 474 (-35.69%)
Mutual labels:  gulp-plugin

gulp-changed

Only pass through changed files

No more wasting precious time on processing unchanged files.

By default it's only able to detect whether files in the stream changed. If you require something more advanced like knowing if imports/dependencies changed, create a custom comparator, or use another plugin.

Install

$ npm install --save-dev gulp-changed

Usage

const gulp = require('gulp');
const changed = require('gulp-changed');
const ngAnnotate = require('gulp-ng-annotate'); // Just as an example

const SOURCE = 'src/*.js';
const DESTINATION = 'dist';

exports.default = () => (
	gulp.src(SOURCE)
		.pipe(changed(DESTINATION))
		// `ngAnnotate` will only get the files that
		// changed since the last time it was run
		.pipe(ngAnnotate())
		.pipe(gulp.dest(DESTINATION))
);

API

changed(destination, options?)

destination

Type: string | Function

Destination directory. Same as you put into gulp.dest().

This is needed to be able to compare the current files with the destination files.

Can also be a function returning a destination directory path.

options

Type: object

cwd

Type: string
Default: process.cwd()

Working directory the folder is relative to.

extension

Type: string

Extension of the destination files.

Useful if it differs from the original, like in the example below:

exports.jade = () => (
	gulp.src('src/**/*.jade')
		.pipe(changed('app', {extension: '.html'}))
		.pipe(jade())
		.pipe(gulp.dest('app'))
);
hasChanged

Type: Function
Default: changed.compareLastModifiedTime

Function that determines whether the source file is different from the destination file.

Built-in comparators
  • changed.compareLastModifiedTime
  • changed.compareContents
Example
exports.jade = () => (
	gulp.src('src/**/*.jade')
		.pipe(changed('app', {hasChanged: changed.compareContents}))
		.pipe(jade())
		.pipe(gulp.dest('app'))
);

You can also supply a custom comparator function which will receive the following arguments and should return Promise.

transformPath

Type: Function

Function to transform the path to the destination file. Should return the absolute path to the (renamed) destination file.

Useful if you rename your file later on, like in the below example:

exports.marked = () => (
	gulp.src('src/content/about.md')
		.pipe(changed('dist', {transformPath: newPath => path.join(path.dirname(newPath), path.basename(newPath, '.md'), 'index.html')}))
		.pipe(marked())
		.pipe(rename(newPath => path.join(path.dirname(newPath), path.basename(newPath, '.md'), 'index.html'))))
		.pipe(gulp.dest('dist'))
);

In-place change monitoring

If you're looking to process source files in-place without any build output (formatting, linting, etc), have a look at gulp-changed-in-place.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].