Book Image

Getting Started with Grunt: The JavaScript Task Runner

By : Jaime Pillora, Bocoup LLC
Book Image

Getting Started with Grunt: The JavaScript Task Runner

By: Jaime Pillora, Bocoup LLC

Overview of this book

Table of Contents (12 chapters)

Project setup


Now we have installed Node.js, npm and Grunt, we're ready to create our first Grunt environment. Let's say we've already built a website, now we want to use Grunt to minify our assets. In this section, we'll learn about the two required files: the package.json file and the Gruntfile.js file, as well as a recommended directory structure.

package.json

The package.json file is a package descriptor; it is used to store all metadata about the module, such as name, version, description, author, repository, and more. It's the single file required to effectively use npm, therefore, the package.json file can also be thought of as the "npm file". As the file extension would suggest, it must be in the JavaScript Object Notation (JSON) data format. If the JSON syntax is invalid, npm will display an error when reading this file. Using a package.json file in our project has many benefits. These include: making it easy to reinstall our dependencies by defining a dependencies field; letting...