Getting started with Gulp

First of all, install the Gulp package globally; this will give you access to the gulp command:

$ npm install -g gulp

Once you have installed Gulp globally, you will need to install it in your local project in order to have access to the Gulp core utilities:

$ npm install -save-dev gulp

To configure the Gulp tasks, you will need to create a file called gulpfile.js that Gulp will read every time you run the gulp command. All Gulp tasks have a name and a function that is executed when the task is invoked:

var gulp = require('gulp');

gulp.task('hello', function() {
  console.log('Hello world!');
});

The following simple Gulp task will print Hello world! on the console:

$ gulp hello
[22:43:15] Using gulpfile ~/path/to/project/gulpfile.js ...

Get Mastering Backbone.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.