Book Image

Mastering Grunt

By : Daniel Li
Book Image

Mastering Grunt

By: Daniel Li

Overview of this book

<p>Grunt.js continues to excel as the build automation tool of choice. Along with its support for many third-party technologies, Grunt is packaged with a clean API for defining tasks. This powerful tool can streamline your workflow by automating the preparation tasks for production, such as compression, compilation, obfuscation, testing, and even pushing your web application live. This book will teach you how to master build automation and testing with Grunt. You will have the opportunity to utilize the latest and in-demand web tools, such as Git, Jade, CoffeeScript, Sass, and the Mocha testing engine, across several exciting projects by combining Grunt with them. You will also learn to create a project – a simple Bulletin Board System (BBS), which will explain the use of Grunt alongside the Mocha testing library to automate testing throughout the build process.</p> <p>Mastering Grunt will demonstrate how to leverage Grunt with other technologies to become an expert in build automation, teaching you the best practices for modern web development along the way.</p>
Table of Contents (12 chapters)

Preface

Grunt.js is primarily used for DevOps integration. Being able to automate compression, conversion, and obfuscation, developers and sysadmins are able to deploy projects in a fast and easy way. Previous solutions have required too much knowledge. With the ease of using Grunt plugins and configuration files, it allows developers to work along with sysadmins throughout the integration process.

What this book covers

Chapter 1, Getting Started, gives a brief introduction to Grunt.js for readers. It will introduce the basic concepts required to understand how Grunt.js works and why automated integration is important. The project in this chapter will set up users with all the tools required for the upcoming projects from this point forward. It covers the installation of software dependencies including Git, Bower, and Grunt.js.

Chapter 2, Developing a Blog with Jade and Sass, will look into Jade, a templating engine originally developed for the Node.js platform. It will involve developing a blog as a use case, using templates for individual posts and the blog as a whole. The project will also emphasize the importance of compression, minification, and obfuscation in developing a high-traffic blog as a use case.

Chapter 3, Making an Employee Management System, will look into CoffeeScript, a language that compiles to JavaScript. It will involve developing an employee management system as a use case, demonstrating CoffeeScript's easy-to-use classes and coding practices.

Chapter 4, Final Project – Simple Bulletin Board System, will be the largest project in the book. It will involve creating a simple BBS website, also known as a message board or forum, using all the concepts involved in this book. We will illustrate the importance of using test-driven development via Mocha throughout this chapter.

Chapter 5, Best Practices for Modern Web Applications, will cover the best practices that are used today for frontend development. It will cover, search engine optimization, form validation, user experience/interface design, and responsive design.

What you need for this book

In order to complete the projects within this book, you will need to have the following available beforehand. A tutorial on how to install and configure the various software dependencies may be found in Chapter 1, Getting Started.

  • A machine that has its default terminal shell set to bash will be required. Mac OS X Version 10.3 or higher will complete this requirement. Most popular distributions of Linux will also come with bash as its default. If your primary operating system is Windows, you can use your existing command line for this book.

  • Git will be required for downloading the project templates from GitHub, an online open source project-hosting service. GitHub will also provide a separate set of online installation instructions for each project on its README page.

  • npm will be used for installing a variety of dependencies including Grunt.js and its plugins. Node.js and server-side concepts will not be covered in this book.

  • Bower is a package management system, which will be used for client-side, frontend JavaScript libraries in this book. It will depend on npm for installation.

  • Lastly, Grunt.js will be required for all projects in this book. Intense emphasis will be put on how to properly configure Grunt.js along with plugins. Grunt.js will depend on npm for installation.

Who this book is for

This book is designed for professional developers and sysadmins who would like an in-depth learning approach to Grunt.js to ensure that their projects are optimally configured. Hobbyist developers are also encouraged to go through the chapters to broaden their horizons on various web tools. Lastly, managers and entrepreneurs may be interested in an overview of Grunt.js and its importance when the tool has been chosen for a particular project.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Open the index.html file in the src folder in a web browser of your choice."

A block of code is set as follows:

// constants and functions

module.exports = function (grunt) {
  grunt.initConfig({
     // configuration
  });

  // user-defined tasks
}

Any command-line input or output is written as follows:

# npm install -g bower

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Fill out the necessary fields on the homepage and click on the Sign Up for GitHub button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.