Hacker News new | ask | show | jobs
by rev087 4477 days ago
I haven't used npm tasks yet, so take this with a grain of salt. Grunt has two main advantages: a rich plugin ecosystem, with easy-to-configure/use tasks for pretty much anything I can think of (preprocessing, concatenating, minifying, linting, live reloading etc.) and a standardized "language" to configure Grunt plugins (third party or your custom tasks).

Once you familiarize yourself with the Grunt way of setting up tasks, it becomes trivially simple to obtain and run plugins for your tasks.

1 comments

Exactly! I actually have grunt tasks pointing to npm "scripts" to run. Here is a sample Gruntfile that does the following:

1. Runs unit tests any time source or test files change

2. Runs JsHint on the source any time it changes

3. Generates a static documentation site based on any edits I make to my markdown files

4. Brings up, tears down vagrant VMs which host a MongoDB (or whatever) instance

This makes development workflow really awesome. Just do "grunt watch" in a terminal, and you will always be able to see your tests go from fail to pass as you develop your (linty clean) code.

I have seen many others use (and mention the use of) Grunt to reboot the server on file change, this is one of those programing austerities I have not given up (yet).

[1] - Sample Gruntfile - https://github.com/sabhiram/nodejs-scaffolding/blob/master/G...

[2] - Grunt Plugins - http://gruntjs.com/plugins