0%

Book Description

Monitor and automate complex JavaScript tasks and processes by obtaining a practical understanding of Grunt

About This Book

  • Gain a solid knowledge of Grunt to achieve better process management by improving consistency, productivity, reliability, and quality of code
  • Install, configure, and use plugins into your project with this hands-on guide
  • This step-by-step tutorial will walk you through practical examples of workflow automation

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.

What You Will Learn

  • Install and configure Grunt and its dependencies such as Node.js and Node Package Manager (NPM)
  • Create a sample application using Angular.JS
  • Configure plugins to perform various tasks that will benefit your project
  • Explore the task-specific methods available through the Grunt API such as configuration, externals, events, and logging
  • Set up tasks to automate the build process of the simple contact application
  • Build, test, and refine a sample project
  • Get general tips, tricks, and troubleshooting strategies to identify and solve common issues in Grunt
  • Advance your knowledge of Grunt with concepts such as configuration variables and test automation

In Detail

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.

Style and approach

This book is an easy-to-follow, step-by-step tutorial that provides explanations and examples of deploying Grunt from scratch.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased 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 code file.

Table of Contents

  1. Learning Grunt
    1. Table of Contents
    2. Learning Grunt
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewer
    7. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Grunt Dependencies
      1. Dependencies
        1. What is Node.js and NPM?
        2. Where can I find Node.js and NPM?
      2. Upgrading or installing Node.js
        1. Upgrading Node.js via NPM on Mac
        2. Upgrading Node.js on Windows via .msi and NPM
        3. The pristine installation of Node.js via downloaded binary
        4. Adding your installation path to your $PATH variable
        5. Using NPM to install the Grunt Command Line Interface
      3. Installing the Grunt CLI
        1. Updating NPM
        2. Installing Grunt CLI
      4. Summary
    10. 2. Foundation for Creating an App using Angular.JS
      1. Installing Git
        1. Determining the Git installation
        2. Creating a temporary alias
        3. Adding Git to your $PATH variable
        4. Installation of Git
      2. Creating the Angular Seed Project
        1. Dependencies of Angular Seed
        2. Cloning the Angular Seed Project
        3. Installing Angular Seed dependencies
        4. Running the Angular Seed Application
      3. Installation summary – a quick guide
        1. Installing Git
        2. Determining Git Installation
        3. Create the Angular Seed Project
      4. Summary
    11. 3. All about Grunt Plugins
      1. Obtaining Grunt plugins
        1. Plugins overview
        2. Actually obtaining Grunt plugins
      2. Common Grunt plugins and their purposes
        1. Linting JavaScript – contrib-jshint
        2. Minifying Javascript – contrib-uglify
        3. Compile LESS into CSS – contrib-less
        4. Desktop notifications for automated tasks – notify
        5. Opening files and URLs automatically – open
        6. Optimizing images – contrib-imagemin
        7. Running tasks only on files that changed – newer
        8. Performing SSH and SFTP tasks – ssh
        9. The minification of CSS – contrib-cssmin
        10. Concatenate files – contrib-concat
        11. Cleaning up files and folders – contrib-clean
        12. Minifying HTML files – contrib-htmlmin
        13. Watch for changing files - contrib-watch
      3. Summary
    12. 4. Configuration of Grunt Tasks
      1. Reviewing the installation of Grunt tasks
        1. Installing contrib-jshint with NPM
        2. Installing contrib-uglify with NPM
        3. Installing contrib-less with NPM
        4. Installing contrib-watch with NPM
      2. Discussing package.json and gruntfile.js
        1. The package.json file
        2. The gruntfile.js file
      3. Introducing the Grunt API
        1. The wrapper function and initConfig
        2. Loading NPM tasks:
        3. Creating tasks
        4. Grunt fail API
        5. The Grunt event API
        6. The Grunt file API
        7. The Grunt log API
        8. The Grunt option API
        9. Grunt Template API
        10. The Grunt task API
      4. Summary
    13. 5. Task Setup in the sample_project Application
      1. Defining requirements of sample_project
        1. An overview of user stories
        2. The slide deck
      2. Gruntfile.js wrapper and configuration
        1. Wrapper
        2. grunt-init-gruntfile
      3. Gruntfile.js configuration
      4. Summary
    14. 6. Building the Sample Project
      1. Understanding task loading
        1. Using the LoadNpmTasks method
        2. Calling plugins using the loadNpmTasks method
        3. Using the devDependencies object looping method
      2. The default task configuration
        1. A custom task configuration
      3. Functional testing
        1. Testing the contrib-jshint configuration
        2. Testing the contrib-uglify configuration
        3. Testing the contrib-less Configuration
        4. Testing the contrib-imagemin configuration
        5. Testing the notify configuration
        6. Testing the open configuration
        7. Testing the contrib-watch Configuration
        8. The Complete Gruntfile.js
      4. Summary
    15. 7. Advanced Grunt Concepts
      1. Creating a Grunt plugin
        1. Using the Grunt plugin scaffold
        2. Authoring a custom plugin
      2. Summary
    16. Index
3.144.33.41