Lately I have been studying Node.js. In this time,I have heard a lot about using Gulp or Grunt in as a build tool. Now I am interested in learning how to use Gulp. I have heard it was a build tool, but I am not sure what all that covers. What would I do(what kind of tasks) with a build tool like Gulp that would assist me in development? Some examples would be nice.
相关问题
- How to test my jQuery plugin with Gulp, Jasmine an
- Gulp BrowserSync showing “reloading browsers” in T
- gulp-iconfont task not populating unicode value
- Start a shell process in Gulp with callback when p
- Gulp is not overwriting the destination file
相关文章
- how can I use babel polyfill to support all IE11 i
- How can I get gulp-typescript to output to the sam
- How to make Gulp.src fail if a file is missing?
- ES6 import module with Gulp
- Visual Studio wants to build with wrong platform t
- Gulp: How to set dest folder relative to processed
- Compile zbar for Python 3.x
- Send arguments to gulp task
Build tools are an asset to application development. Few years back, it was common for project managers to run behind the developers asking them to clean up the code, lint the code, increase the performance of the application etc.
The usual modus operandi of developers was to make a copy of the 'Development' environment code for the Production environment and do the required operations. Developers would use third party software or apps that helps in cleaning up the code like removing unnecessary comments, minifying to decrease the overall size of the file and thereby the application, concatenating the files so that you decrease the number of hits to the server, perform unit tests, to name a few.
What build systems like Gulp and Grunt have done is that it automates all the above mentioned tasks in a span of few seconds. These build systems have specific plugins that does concatentation, minification, linting, environment specific development etc. All these tasks run in one go performing the required operations, in turn running the application from the newly formed production code.
The advantage of using build system is that it accelerates your application's page load time to a greater extent. Your code is cleaner, smaller in size and at the same time adheres to the best coding practices. And in turn , you save a lot of time which was spent doing each of these tasks.
They are pretty easy to work with and should be used in application development. :-)
Gulp ( and Grunt ) allows for task automation.
Pretty much anything you find yourself doing repeatedly in a project, can be automated with gulp and it's plugins. and if you can't find a plugin to do the job for you, gulp is just a nodejs app, so you can quickly write your own code to do the job.
As far as examples, since I myself am an angular web developer, I will give you examples from the Front End Development land, but don't think gulp is only limited to this area. So here are some examples :
Another interesting benefit you get with JavaScript build tools specifically ( as opposed to Java's Ant or Rails's Rake ), is that most of all web applications out there use JavaScript. So if your back end is in Java or Rails or C++ ... your front end people always rejoice under JavaScript. Which means that, no matter what language you use, you STILL use JavaScript ... Which makes tools like gulp very interesting, because JavaScript and JavaScript experience is guaranteed to exist in any Web Development team.
I guess I'll update this in time to make it clearer. Until then have a look at :
http://gulpjs.com/plugins/ to get an idea of some of the easy to obtain functionality you can get with gulp.
Here's a quick code example, of a gulp task, that takes your project's images, and moves them into your dist folder :
Tasks can be chained together and rely on eachother. Notice how the task 'images' depends on 'clean' . That means that if you want to run 'images' your 'clean' task will automatically get called before. This allows you to chain tasks together, for very powerful reusable task sequences. Here's an example of how 'clean' could look like :
Here's some random page i found with a google search. It contains a very clear coffeescript file with examples of gulp automation tasks in a Front End project : http://pem-musing.blogspot.ca/2014/02/a-gulp-of-coffee-your-gulpfile-in.html
Hope this helps
Gulp JS is a Javascript based tool which allows you to automates the tasks of your workflow. Automation can literally increase your production. Whether you’re a developer or a designer who creates HTML wireframes now and then, we recommends to dig into that.
http://www.jshive.com/getting-started-gulp-task-runner/