gulp
The streaming build system
Like what we do?
Documentation
For a Getting started guide, API docs, recipes, making a plugin, etc. see the documentation page!
gulpfile.js
Sample This file is just a quick sample to give you a taste of what gulp does.
var gulp = ;var coffee = ;var concat = ;var uglify = ;var imagemin = ;var sourcemaps = ;var del = ; var paths = scripts: 'client/js/**/*.coffee' '!client/external/**/*.coffee' images: 'client/img/**/*'; /* Register some tasks to expose to the cli */gulp;gulp;gulp; // The default task (called when you run `gulp` from cli)gulp; /* Define our tasks using plain functions */ // Not all tasks need to use streams// A gulpfile is just another node program and you can use all packages available on npm { // You can use multiple globbing patterns as you would with `gulp.src` ;} // Copy all static images { return gulp // Pass in options to the task ;} // Minify and copy all JavaScript (except vendor scripts)// with sourcemaps all the way down { return gulp ;} // Rerun the task when a file changes { gulp; gulp;}
Incremental Builds
You can filter out unchanged files between runs of a task using
the gulp.src
function's since
option and gulp.lastRun
:
{ return gulp ;} { gulp;}
Task run times are saved in memory and are lost when gulp exits. It will only
save time during the watch
task when running the images
task
for a second time.
If you want to compare modification time between files instead, we recommend these plugins:
- gulp-changed;
- or gulp-newer - supports many:1 source:dest.
gulp-newer example:
{ var dest = 'build/img'; return gulp // pass through newer images only ;}
If you can't simply filter out unchanged files, but need them in a later phase of the stream, we recommend these plugins:
- gulp-cached - in-memory file cache, not for operation on sets of files
- gulp-remember - pairs nicely with gulp-cached
gulp-remember example:
{ return gulp // only pass through changed files // do special things to the changed files... // for example, // add a simple module wrap to each file // add back all files to the stream // do things that require all files }
Want to contribute?
Anyone can help make this project better - check out the Contributing guide!