Why use a task runner?

In one word: automation. The less work you have to do when performing repetitive tasks like minification, compilation, unit testing, linting, etc, the easier your job becomes. After you’ve configured it through a Gruntfile, a task runner can do most of that mundane work for you—and your team—with basically zero effort.

Why use Grunt?

The Grunt ecosystem is huge and it’s growing every day. With literally hundreds of plugins to choose from, you can use Grunt to automate just about anything with a minimum of effort. If someone hasn’t already built what you need, authoring and publishing your own Grunt plugin to npm is a breeze. See how to get started.

Getting started

Grunt and Grunt plugins are installed and managed via npm, the Node.js package manager. Grunt 0.4.x requires stable Node.js versions >= 0.8.0. Odd version numbers of Node.js are considered unstable development versions.

Before setting up Grunt ensure that your npm is up-to-date by running npm update -g npm (this might require sudo on certain systems).

If you already have installed Grunt and are now searching for some quick reference, please checkout our Gruntfile example and how to configure a task.

Installing the CLI

In order to get started, you’ll want to install Grunt’s command line interface (CLI) globally. You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to do this.

npm install -g grunt-cli

This will put the grunt command in your system path, allowing it to be run from any directory.

Note that installing grunt-cli does not install the Grunt task runner! The job of the Grunt CLI is simple: run the version of Grunt which has been installed next to a Gruntfile. This allows multiple versions of Grunt to be installed on the same machine simultaneously.

How the CLI works

Each time grunt is run, it looks for a locally installed Grunt using node’s require() system. Because of this, you can run grunt from any subfolder in your project.

If a locally installed Grunt is found, the CLI loads the local installation of the Grunt library, applies the configuration from your Gruntfile, and executes any tasks you’ve requested for it to run. To really understand what is happening, read the code.

Working with an existing Grunt project

Assuming that the Grunt CLI has been installed and that the project has already been configured with a package.json and a Gruntfile, it’s very easy to start working with Grunt:

  1. Change to the project’s root directory.
  2. Install project dependencies with npm install.
  3. Run Grunt with grunt.

That’s really all there is to it. Installed Grunt tasks can be listed by running grunt --help but it’s usually a good idea to start with the project’s documentation.


Grunt: The JavaScript Task Runner

Learn more..

David

I’m freelance graphic, website designer. Currently, I get into the secrets of the world of Fedora Linux, SSH, WP-CLI and I’m preparing this blog about WordPress.

More:

Top 11 Features of Windows 8 Dot Com Infoway (DCI), has created yet another infographic illustrating the best features of Windows 8. “Top 11 Features of Windows 8” is the 5th in a...
How to move Your Web Hosting from Shared to VPS Se... Most entry-level businesses start out with shared hosting. All shared hosting plans have a control panel and the most widely used ones are DirectAdmin...
Language Translation Plugins for WordPress As a web owner you must be obsessed with statistics and analytics. If you happen to take a careful look at your website’s statistics you might find th...
The Ultimate Video Guide to WORDPRESS The Ultimate Video Guide to WordPress Help You Churn Out Site after Site almost at Will the Very First Time You View Them…!!! This is an absolute mus...
A Showcase of Clean Minimalist Logos Welcome to our Showcase of Clean Minimalist Logos. A logo has to work incredibly hard. It has to advertise a company, give an idea of what the company...

Leave a Reply


Close Menu

Pin It on Pinterest