I’m a recent convert to using Grunt.js to run tasks that are an essential part of my development workflow. Grunt is a command-line tool that lets you run a heap of tasks in one command, all customized to your liking and tailored to your project’s needs. It helps me automate repetitive jobs like CSS preprocessing, or minifying code for a production environment.
Pick a Task
index.htmlin the browser.
Install Node.js and Grunt’s Command Line Interface
Before we can install these plugins, we need Node.js on our computer. Luckily, it’s an easy install for Windows or Mac OS. Just go to nodejs.org and click the big green INSTALL button to download.
Once you’ve installed Node.js, you need Grunt’s Command Line Interface tools on your computer. From a terminal window, run
npm install -g grunt-cli. If you get a permissions error, I suggest reading this article on npm. This article, written by Isaac Schlueter, will teach you how to install modules without using sudo.
package.jsonto Your Project
You need two files for every project that uses Grunt –[js]
Gruntfile.js. Start by adding
package.jsonto your project folder, in the root. You can use the basic contents from the Grunt.js setup instructions, substituting with your project’s info. With time you’ll evolve your own starter kit for projects. Here’s my default Grunt project‘s
“author”: “Catherine Farman”,