GRUNT – JavaScript Build Tool For Everyone

It doesn’t matter if you are a high level developer or

grunt

a newbie – Grunt can help you. I will share a few practical ways

Minify your codethat I use Grunt, although I can for sure do a lot more with Grunt than just those solutions that I will discuss I will only discuss only a few of my favorites. Also I am still in the learning process of all of the benefits of Grunt, so if you have a usage that you think is important and is not listed here, please share! All of my current usages for Grunt is for static resources.

With Grunt you can easily minify your code into a destination file. The most common way to minify a file with Grunt is to use Uglify.js. there is a lot of information on the Grunt website on how to get started.

Combine a few JavaScript files

With Uglify you can combine a few files into one file – that is great for configuration files. If you have different configuration values on your development server than your production server – just make all your configurations on a separate file and combine it with Grunt. The build will be per server.

There are a lot of ways to handle configuration in JavaScript. The most obvious is to just put it in the script without thinking about it too much. That solution is good only if you test everything on production, but for those sane developers like us that want to test our scripts on multiple environments we need a good way to easily move our scripts from one environment to the other. With Grunt it is easy to do so – use a settings file that is combined during the build process

JSLint

you can put JSLint as part of the build process, personally I don’t use that feature since I use JSLint directly into my IDE, but that can be useful for other people.

Testing

We can integrate our tests with the Grunt build. This is extremely useful since I can integrate the testing process directly to the build process and when the test is failing – I will get an immediate feedback.

Reformatting code

remove all of your debugging code on the build, that way no accidental console.log statements on the real script.

How to install?

A great in depth manual is in the Grunt website. It is depended on Node.js.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">