Grunt Cookbook

Over 80 hands-on recipes for streamlining development, management, and deployment with Grunt

Grunt Cookbook

Cookbook
Jurie-Jan Botha

Over 80 hands-on recipes for streamlining development, management, and deployment with Grunt
$28.80
$36.00
RRP $35.99
RRP $44.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781783286515
Paperback286 pages

About This Book

  • Describes how to implement automation solutions for common web application development tasks
  • Explores configuration variations that are available to the plugins used in each recipe
  • A practical guide with clear and concise instructions to build entire web applications easily using Grunt.js

Who This Book Is For

This book will be useful to anyone who wishes to build anything from a static website to a more modern web application. Some basic JavaScript experience is preferable and some rudimentary knowledge of the Node.js platform could also come in handy.

Table of Contents

Chapter 1: Getting Started with Grunt
Introduction
Installing the Grunt CLI
Setting up Grunt in a project
Installing a plugin
Setting up a basic web server
Watching files for changes
Setting up LiveReload
Processing only changed files
Importing external data
Chapter 2: File Management
Introduction
Copying files
Compressing files
Creating symbolic links
Concatenating files
Fetching a single URL
Fetching multiple URLs
Chapter 3: Templating Engines
Introduction
Rendering Jade templates
Using data in a Jade template
Using custom filters in a Jade template
Compiling Jade templates
Compiling Handlebars templates
Compiling Underscore templates
Using partials in Handlebars templates
Wrapping Jade templates in AMD modules
Wrapping Handlebars templates in AMD modules
Wrapping Underscore templates in AMD modules
Wrapping Handlebars templates in CommonJS modules
Altering Jade templates before compilation
Altering Handlebars templates before compilation
Altering Underscore templates before compilation
Chapter 4: Generating CSS and JavaScript
Introduction
Compiling LESS to CSS
Compiling Sass to CSS
Compiling Stylus to CSS
Compiling CoffeeScript to JavaScript
Compiling LiveScript to JavaScript
Generating source maps for LESS
Generating source maps for Sass
Generating source maps for CoffeeScript
Defining custom functions with LESS
Using Stylus plugins
Chapter 5: Running Automated Tests
Introduction
Running Jasmine tests
Running QUnit tests
Running NodeUnit tests
Running Mocha client-side tests
Running Mocha server-side tests
Generating coverage reports for server-side code using Mocha and Blanket
Generating coverage reports for client-side code using Mocha and Blanket
Generating coverage reports for client-side code using QUnit and Istanbul
Chapter 6: Deployment Preparations
Introduction
Minifying HTML
Minifying CSS
Optimizing images
Linting JavaScript code
Uglifying JavaScript Code
Setting up RequireJS
Chapter 7: Deploying to the End User
Introduction
Deploying to Rackspace Cloud Files
Deploying to AWS S3
Deploying over FTP
Deploying over SFTP
Deploying to GitHub Pages
Invalidating an AWS CloudFront distribution
Running commands over SSH
Chapter 8: Creating Custom Tasks
Introduction
Creating an alias task
Creating a basic task
Accessing project configuration
Checking for required configurations
Checking for the successful execution of other tasks
Running non-blocking code in a task
Failing a task
Using command-line parameters
Enqueuing tasks to run
Creating a multi-task
Using options in a task
Using files in a task
Chapter 9: Authoring Plugins
Introduction
Finding plugins
Contributing to a plugin
Setting up a basic plugin project
Creating a plugin task
Writing tests for a plugin task
Adding documentation for a plugin
Publishing a plugin
Chapter 10: Static Sites
Introduction
Setting up a basic site project
Adding a page to the site
Adding content to the site
Adding data to the site
Creating and using a site layout
Generating pages from a collection
Using a plugin

What You Will Learn

  • Automate CSS generation
  • Manage asynchronous work inside a task
  • Automate HTML and CSS template compilation
  • Manage entire web applications using Grunt
  • Automate various levels of testing
  • Build and publish custom tasks and plugins
  • Automate CoffeeScript and LiveScript code compilation

In Detail

A web application can quickly turn into a complex orchestration of many smaller components, each one requiring its own bit of maintenance. Grunt allows you to automate all the repetitive tasks required to get everything working together by using JavaScript, the most popular programming language.

Grunt Cookbook offers a host of easy-to-follow recipes for automating repetitive tasks in your web application's development, management, and deployment processes. This book will introduce you to methods that can be used to automate basic processes and your favorite tools. By following the recipes, you will soon be comfortable using Grunt to perform a wide array of advanced tasks in a range of different scenarios.

Authors

Table of Contents

Chapter 1: Getting Started with Grunt
Introduction
Installing the Grunt CLI
Setting up Grunt in a project
Installing a plugin
Setting up a basic web server
Watching files for changes
Setting up LiveReload
Processing only changed files
Importing external data
Chapter 2: File Management
Introduction
Copying files
Compressing files
Creating symbolic links
Concatenating files
Fetching a single URL
Fetching multiple URLs
Chapter 3: Templating Engines
Introduction
Rendering Jade templates
Using data in a Jade template
Using custom filters in a Jade template
Compiling Jade templates
Compiling Handlebars templates
Compiling Underscore templates
Using partials in Handlebars templates
Wrapping Jade templates in AMD modules
Wrapping Handlebars templates in AMD modules
Wrapping Underscore templates in AMD modules
Wrapping Handlebars templates in CommonJS modules
Altering Jade templates before compilation
Altering Handlebars templates before compilation
Altering Underscore templates before compilation
Chapter 4: Generating CSS and JavaScript
Introduction
Compiling LESS to CSS
Compiling Sass to CSS
Compiling Stylus to CSS
Compiling CoffeeScript to JavaScript
Compiling LiveScript to JavaScript
Generating source maps for LESS
Generating source maps for Sass
Generating source maps for CoffeeScript
Defining custom functions with LESS
Using Stylus plugins
Chapter 5: Running Automated Tests
Introduction
Running Jasmine tests
Running QUnit tests
Running NodeUnit tests
Running Mocha client-side tests
Running Mocha server-side tests
Generating coverage reports for server-side code using Mocha and Blanket
Generating coverage reports for client-side code using Mocha and Blanket
Generating coverage reports for client-side code using QUnit and Istanbul
Chapter 6: Deployment Preparations
Introduction
Minifying HTML
Minifying CSS
Optimizing images
Linting JavaScript code
Uglifying JavaScript Code
Setting up RequireJS
Chapter 7: Deploying to the End User
Introduction
Deploying to Rackspace Cloud Files
Deploying to AWS S3
Deploying over FTP
Deploying over SFTP
Deploying to GitHub Pages
Invalidating an AWS CloudFront distribution
Running commands over SSH
Chapter 8: Creating Custom Tasks
Introduction
Creating an alias task
Creating a basic task
Accessing project configuration
Checking for required configurations
Checking for the successful execution of other tasks
Running non-blocking code in a task
Failing a task
Using command-line parameters
Enqueuing tasks to run
Creating a multi-task
Using options in a task
Using files in a task
Chapter 9: Authoring Plugins
Introduction
Finding plugins
Contributing to a plugin
Setting up a basic plugin project
Creating a plugin task
Writing tests for a plugin task
Adding documentation for a plugin
Publishing a plugin
Chapter 10: Static Sites
Introduction
Setting up a basic site project
Adding a page to the site
Adding content to the site
Adding data to the site
Creating and using a site layout
Generating pages from a collection
Using a plugin

Book Details

ISBN 139781783286515
Paperback286 pages
Read More