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
[22:43:15] Starting 'hello'...
Hello world!
[22:43:15] Finished 'hello' after 118 μs

Note how we invoke Gulp, gulp hello, the argument used in the command is the name of the task to be executed. This is the simplest Gulp task that you can write and it is the starting point for developing an effective build pipeline.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.144