Behold! The 3rd post on automated build/dev processes for the web.
This time we’re looking at Grunt. We’re looking at Grunt because I blew up by Guard setup on Windows (who knew gem update could be a bad idea) and used the opportunity to give Grunt another look. I poured myself a beer, swaggered over to my standing desk, and didn’t move until I figured it out. I’m really glad I did - Grunt is my new best friend.
To get Grunt up and running you need to install Node, then install Grunt via the node package manager (npm): npm install -g grunt-cli. I’m using 5 modules that can also be installed with npm:
You will typically create a package.json file that contains, among other things, your dependencies. If you’ve got one, you can just run npm install and it’ll read it and grab whatever is missing. To create a package.json file from your current dependencies run npm init. A typical package.json file looks like this:
The serious grunt stuff goes in Gruntfile.js. When you look at this one you might throw up in your mouth a little bit. Yes, I was doing all of this in 12 lines of Ruby + 14 lines of shell script. Yes, that’s a lot less than ~120 lines of code. Hang with me here.