Gulp is the streaming build system. Gulp’s use of streams and code-over-configuration makes for a simpler and more intuitive build. I didn’t use Gulp or Grunt before. Today, I hear about it and decide to use it on my project. What I write here is not a tutorial, it just what I do with Gulp.
To install Gulp we must have node installed. Nodejs can be installed from here http://nodejs.org/
– Gulp: We should install gulp globally
gulp-util in your project as
devDepencies. Before it you should have
package.json file in your project or init it by
--save-dev will let
devDepencies of file
gulpfile.js at your project root with bellow simple content:
Above is just some step to get started with gulp. You can find here https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md
I want do more with gulp in my project, such as minify JS code, build LESS code to CSS… Let install some gulp plugins and write some simple code. Gulp plugins can be found here: http://gratimax.github.io/search-gulp-plugins/
As my requirement I will install
Now, we create (make) some tasks for gulp by writing code.
There are 4 gulp tasks and they can be called by commands:
jshint: This task will check all JS file in folder
/jsand report error.
minify: This task will get all JS files in folder
/js, minifies them and save to folder
less: This task will convert all LESS files in folder /less to CSS and save to folder
default: This task will run 3 above tasks and add watching for JS, LESS files. If JS files in folder
/jschange, it will run task jshint and minify. The same with LESS file in folder
- Install NodeJS
- Install Gulp and its plugins
- Create Gulp tasks for our project
This is the first time I using gulp, if you have any info or ideal about gulp feel free to comment and let me know. Very thank you for your comments.