Gulp is a streaming build system. I found it is much easier than Grunt.

The differene between Gulp and Grunt (slide):

  • With Gulp your build file is code, not config.
  • You use standard libraries to do things.
  • Plugins are simple and do one thing - most are a ~20 line function.
  • Tasks are executed with maximum concurrency.
  • I/O works the way you picture it.


# install gulp globally
$ npm install -g gulp
# install gulp in project
$ npm install --save-dev gulp


# run gulp default task
$ gulp
# run specific gulp tasks
$ gulp <task> <othertask>
# list all gulp tasks
$ gulp -T


Create a gulpfile.js at the root of project directory.

var gulp = require('gulp');

gulp.task('default', function(){
  // place code for your default task here

Gulp APIs

There are four APIs in gulp:

  • gulp.src(globs[, options])
  • gulp.dest(path)
  • gulp.task(name[, deps], fn)
  •, tasks)

Refer to API Docs.


# install gulp plugins
$ npm install gulp-coffee gulp-less --save-dev

Some plugins: More

Sample Tasks

Compile CoffeeScript

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

gulp.task('coffee', function() {
      .pipe(coffee({ bare: true }))

Compile Less

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

gulp.task('less', function() {
      .pipe(less({ compress: true }))

Copy Files

gulp.tasks('copy_files', function() {

Watch File Changes

gulp.task('watch', function() {'coffee/*.coffee', ['coffee']);'less/*.less', ['less']);