Implementation of Gulp.js from Scratch

Table of contents
Reading Time: 3 minutes

Are you tired of doing  the same things manually i.e., creating the folders, compiling and copying  the files deploying them on separate environments (i.e., dev or prod) manually.  A lot of mouse clicking,  lot of  copy-paste, a lot of configuration changes and of course loads of headache.

Then this blog is for you.

I hope after this blog your search ends for implementing gulp in your project and brings you the clarity.

Today we’ll be covering following subjects in this post:

  • Basics of gulp.
  • Setting the gulp.
  • Running a simple task through gulp.

So, enough of chit-chats, lets jump !!

What exactly is GULP ?

Gulp is a task/build runner for development. It allows you to do a lot of stuff within your development workflow. You can compile SASS files, uglify and compress the .js files and much more. The kicker for gulp is that it is a streaming build system which doesn’t write temporary files. It is like Pipes in bash.

In simple terms Gulp is a tool by which we can automate repetitive tasks . It won’t revolutionize your automation but simplifies it tremendously. ” 

Why use GULP ?

Lets take a hypothetical scenario, suppose you have an app named as sampleApp, and to see this application in action you have to perform series of following hypothetical tasks:

  • Creating and copying the files to development/production environment folder.
  • Creating concatenated, minified and uglified version of application files.
  • Change the configuration file according to the development/production environment.
  •  some other extra tasks….

Yes !! you can do these tasks manually but for how long? To save you a lot of time and to save you from boredom, gulp will play like Tony Stark jarvis :p

This is because you will be focusing on your functionality and nothing else.


Gulp is easy to install and to run. The steps are:

  • Install Gulp Globally.
  • Initialize your project directory
  • Install Gulp In devDependencies.
  • Create a gulpfile.js
  • Run gulp.

You need to have Node.js (Node) installed onto your computer before you can install Gulp.

If you do not have Node installed already, you can get it by downloading the package installer from Node’s website.

When you’re done with installing Node, you can install Gulp by using the following commands in the command line:

The first step is to get gulp installed globally.

Note:  If you have previously installed a version of gulp globally, please run npm rm –global gulp to make sure your old version doesn’t collide with gulp-cli.

$ npm install --global gulp-cli

Make sure that you have your package.json created . You can either create it manually or type write below command.

$ npm init

After that, you’ll need gulp as a devDependency on any of your project you want to use it in. Once you have your package.json, let’s install gulp into devDependencies with:

$ npm install --save-dev gulp
$ npm install --save-dev gutil

Create a gulpfile.js at the root of your project:

var gulp = require('gulp');
var gutil = require('gulp-util');

gulp.task('default', function() {
 return gutil.log('Gulp is running!')
$ gulp

The default task will run and show you the “Gulp is running!” message.

To run individual tasks, use gulp .

So this is it, you are good to go. You have your basic infrastructure ready now and you can implement as much tasks as per your needs.

We’ve just scratched the surface of GULP. In the future blog post of this series we’ll be covering the advanced section. So, stay tuned till then.  Love and Peace.