small medium large xlarge

Automate with Grunt: The Build Tool for JavaScript


Cover image for Automate with Grunt

Automate with Grunt

The Build Tool for JavaScript


Grunt is everywhere. JavaScript projects from jQuery to Twitter Bootstrap use Grunt to convert code, run tests, and produce distributions for production. It’s a build tool in the spirit of Make and Rake, but written with modern apps in mind. This book gets you up to speed with Grunt using practical hands-on examples, so you can wrangle your projects with ease. You’ll learn how to create and maintain tasks and project builds, and automate your workflow with plugins and custom tasks.

2014 Jolt Award Finalist!

*In discussing this book, one of the Jolt Award judges lamented that there were not more inexpensive, single-topic, hands-on manuals that give you all you need to know in a direct and approachable style. This observation is spot on in this era of carelessly written manuals and defective documentation. However, Automate With Grunt is one of the few manuals that amply fulfills this simple mission. If you write apps primarily with JavaScript, this is the book to get and keep within reach.

—Andrew Binstock, editor in chief, Dr. Dobbs’ Journal*

Customer Reviews

Whether you’re still writing your first Grunt task or trying to come up with a complex
workflow, this compact and pragmatic book will prove to be a handy companion and
give you the confidence to explore the full and rich Grunt ecosystem.

- Peter Cooper

Managing editor, JavaScript Weekly

This book focuses on how Grunt works and not on the “just do this; just do that” steps
that you typically see in blog posts and documentation. Brian quickly and effectively
shows how to integrate Grunt into your own workflow and how to customize your
workflow for ultimate web-development productivity.

- Jenna Pederson

Independent Developer, 612 Software Foundry

I’ve spent countless hours working with Grunt to build a developer tool called Lineman.
Unfortunately, Grunt’s documentation alone was never enough to show me the simplest,
most conventional way to accomplish what I needed. If I’d had this book to help me
back when I first started, I would have established a deeper, meaningful understanding
of Grunt much more quickly!

- Justin Searls

Co-Founder, Test Double, LLC

This book is a quick and easy dive into a task-running tool whose power and simplicity
are surprising. The examples in this book are fun to follow and also incredibly
practical for any developer.

- Jessica Janiuk

Front-end developer

See All Reviews

Choose Your Format(s)

  • $11.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

This book covers Grunt 0.4.1 and higher, and requires basic knowledge of JavaScript and command-line tools on Windows, OS X, or Linux.

Contents & Extracts

  • Acknowledgments
  • Preface
    • What’s in This Book
    • Who Should Read This Book
    • What You Need
    • Conventions
    • Where to Go for Help
  • The Very Basics excerpt
    • Installing Grunt and Configuring a Gruntfile
    • Our First Task
    • Handling Parameters
    • Throwing Errors
    • Chaining Tasks
    • Describing Tasks
    • What’s Next?
  • Manage Files
    • Creating the Project
    • Creating and Deleting Directories
    • Recursive File Copying
    • Using Values from Files
    • What’s Next?
  • One Task, Many Outputs
    • Introducing Multitasks
    • Multitasks and Files
    • What’s Next?
  • Build a Workflow
    • Creating the App
    • Wrangling the JavaScript
    • Adding Some Style
    • Simplifying the Build
    • Watching Files for Changes
    • Refreshing the Browser Automatically
    • What’s Next?
  • Create a Plug-in
    • The Structure of a Plug-in
    • Creating the Plug-in Skeleton
    • Building Our Plug-in’s Logic
    • Using JSHint to Check for Errors and Problems
    • What’s Next?
  • Create Project Scaffolds
    • Using Existing Templates
    • Creating a Custom Template
    • Including Files Conditionally
    • Including File Contents Conditionally
    • What’s Next?


Brian P. Hogan is an author, editor, teacher, and web developer. When not hacking on Ruby or JavaScript code, he’s mentoring students, writing songs, watching “The Simpsons” and spending quality time with his wife and daughters.