Gulp Basics

In our project we are doing many manual tasks such as copying file, concatenating file, minifying source files.

During project development, few hours get wasted just to copy,minify, concat and build related tasks. These tasks are generally non productive in nature which does not add any productivity in the project. Such build tasks can be automated using gulp.

Build System

Build System is a process to automate the repetitive work by using set of tasks. Set of tasks are collectively called as Task runner.

We will take a glance at some of the examples of tasks and we will classify those into different categories -

TaskCategory of the Task
Coding a moduleDevelopment Task
Writing CSS StyleDevelopment Task
Writing JS FunctionDevelopment Task
Writing Preprocessor using SCSSDevelopment Task
Compiling preprocessor for CSSBuild Task
Concatenating style sheetsBuild Task
Minifying CSS stylesBuild Task
Minifying HTML/JS filesBuild Task
Concatenating script filesBuild Task
Reducing size of imagesBuild Task
Reloading serverBuild Task
Creating production or deployment build to store at particular locationBuild Task

Components of Build System

Build system works with 3 components −

  1. Package managers
  2. Preprocessors
  3. Task runners and build tools

Package Managers

It is used to -

  • Automate the installation process
  • Automate the installation upgrade
  • Automate the installation of required depedencies
  • Clean libraries

Some of the examples of package managers are bower and npm.


Using preprocessor we can define and write code in optimized and efficient way which upon compilation converted into native language. i.e Conside below example of Jade i.e HTML Preprocessor -

Few examples of popular preprocessors are −

Native LanguagePreprocessor
HTMLMarkdown, HAML, Slim, Jade
CSSSASS, LESS and Stylus
JSCoffeeScript, LiveScript, TypeScript

Task Runners

We have already studied the task runner which is used to automate tasks such as SASS/LESS to CSS conversion, minify source files and optimize images

Native LanguageTask Runners
JavaANT, Buildr
JS, UI & Front EndGrunt, Gulp