Book Image

Learning Grunt

By : Douglas Reynolds
Book Image

Learning Grunt

By: Douglas Reynolds

Overview of this book

With the increasing focus on task automation, the Grunt task runner is a vast platform that allows you to incorporate automation into your workflows. At the outset, you will learn how to use Node.js and NMP through an example. You will then find out how to build a sample app and the development environment for it. You will further delve into the implementation of Grunt plugins and the configuration of Grunt tasks. Furthermore, you will explore the various methods and packages for workflow automation. The final chapter will cover some advanced concepts, such as configuration variables and how to create a Grunt plugin. By the end of the book, you will have gained the fundamentals of Grunt and progressed through advanced concepts, including building a Grunt plugin.
Table of Contents (15 chapters)

Preface

The essence of workflow automation is an exemplification of at least two of the three great virtues of a programmer.

 

There are three great virtues of a programmer: laziness, impatience, and hubris.

 
 --–LarryWall, Programming Perl (1st edition), Oreilly And Associates

Larry Wall went on to explain that laziness is the quality that makes you go to great effort to reduce overall energy expenditure. Grunt provides task automation to relieve the developer of the mundane, repetitive processes that occur during software development. Expending effort up front with Grunt will pay dividends in reduction of energy expenditure in the development lifecycle. Impatience, Larry Wall said, makes you write programs that don't just react to your needs but actually anticipate them. Grunt automation can react to your needs by responding to events, such as file changing. With the right combination of tasks and configurations, Grunt automation can even seem as if it is anticipating your next step. Learning Grunt aims to provide you with a ramp from getting up and running to developing your own Grunt plugin. If you are at all lazy and impatient, in the context of a virtuous programmer, then Learning Grunt has been written just for you.

What this book covers

Chapter 1, Grunt Dependencies,will let us know that Grunt is a Javascript task runner, the purpose of which purpose is task automation. Before we can get started with Grunt, we need to make sure we understand and implement Grunt's prerequisites.

Chapter 2, Foundation for Creating an App using Angular.JS, will create a sample application to use throughout this book with the Angular-Seed scaffold.

Chapter 3, All about Grunt Plugins, introduces a sampling of common Grunt plugins, overview of their purposes, brief examples of implementation, and additional references and information.

Chapter 4, Configuration of Grunt Tasks, As we became familiar with installation and configuration of Grunt tasks. Focus is placed on two main files in a Grunt project; package.json and Gruntfile.js.

Chapter 5, Task Setup in the sample_project Application, defines the sample_project automated build process, introduces user stories, and then covers Gruntfile.js configuration from top to bottom.

Chapter 6, Building the Sample Project, will explain the process of loading tasks. We check functionality to ensure we get the expected results, and create custom and default tasks in order to automate the build process.

Chapter 7, Advanced Grunt Concept, will help you create your own custom task. Learn how to use the Grunt plugin tool and then write a custom Javascript plugin to Gzip files into a deployment directory

What you need for this book

Any modern Windows, Linux, or Macintosh computer, a text editor, command-line or terminal interface, and an Internet connection will meet the requirements of this book. Node.js is very lightweight and requires a minimal amount of RAM. The sample project will require approximately 500 MB of storage, although 1 GB of storage is recommended.

Who this book is for

If you are a JavaScript developer and want to learn project monitoring and automation using Grunt, then this book is for you. Basic knowledge of Node.js and Angular.js is assumed. However, no previous experience using Grunt.js is required.

Conventions

In this book, you will find a number of text styles 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: We can include other contexts through the use of the include directive.

A block of code is set as follows:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

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

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
      /etc/asterisk/cdr_mysql.conf

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in 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 at 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.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

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 could 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/submit-errata, 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 to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.