Gulp js streaming build system

well if you are familiar with Grunt, this is another alternative task build tool Gulp, which is easier and flexible than Grunt

npm install -g gulp

If you are not familiar with Grunt or Gulp which both are tools that help you improve your workflow such as automated your script compiling, lint, minify it and output into another folder, every time you made an change. Its awesome tool that was built.

It just happened that I was reading some news and got into this Gulp thing and start exploring it, and found that its awesome and much easier to use than Grunt.

both are built in node, so you need to install the node module when you start an project,

at the root of your project folder, enter this in your terminal

npm install gulp —save

this will install, and now you can start creating a node script file, gulpfile.js

gulp use each plugin for each different task and thats a great concept, there are only 5 functions that you need know,

gulp.task // create a new task or action 

gulp.src // the source of this file start with same folder as gulpfile.js

gulp.run // run the task / action

gulp.watch // watch this folder or file if made some changes

gulp.dest // the destination of folder to output

Below is an example of how Gulp file work using gulp-sass plugin which will compile scss to css, if you are interested to read more, I suggest that you go directly to the gulp github repo. By the way when I install gulp using older version of Node.js I faced some problem watching the file, so you might want to update your node.js.

var sass = require(‘gulp-sass’);
var gulp = require(‘gulp’);
gulp.task(‘dosass’,function(){
gulp.src(‘sass/*.scss’).pipe(sass()).pipe(gulp.dest(‘./sass/css’));
})
gulp.task(‘default’, function() {
  gulp.run(‘dosass’);
  gulp.watch(‘sass/*.scss’, function(event){
    gulp.run(‘dosass’);
  })
})