Getting Started with Grunt: The JavaScript Task Runner

Book description

If you know JavaScript you ought to know Grunt ? the Task Runner for managing sophisticated web applications. From a basic understanding to constructing your own advanced Grunt tasks, this tutorial has it all covered.

In Detail

In recent times, modern web browsers have become the application platform of choice. Grunt, along with its wide range of plugins, provides a simple way of managing the large number of build tasks required to maintain a sophisticated web application.

Getting Started with Grunt: The JavaScript Task Runner provides you with all the information you need to become an effective Grunt power-user. You will quickly learn how to install, configure, and run Grunt. You will go on to understand how to use third-party Grunt and then create your own Grunt tasks that cater to your particular needs.

This book first demonstrates various Grunt use cases before running through the steps of installing, configuring, running, and customizing Grunt. You will learn how to install Node.js, the Node.js package manager (npm), and Grunt. Then, you will understand how to set up and configure a personalized Grunt environment. Next, you will look at the various methods of running and customizing Grunt to utilize its flexibility. Finally, to emphasise what has been learnt, you will see a complete example build of a web application.

Getting Started with Grunt: The JavaScript Task Runner will enable you to create your very own Grunt environments from scratch and fully utilize Grunt's large feature set to effectively solve your custom requirements.

What You Will Learn

  • Learn about Grunt and its advantages
  • Understand Node.js and how it relates to Grunt
  • Take an in-depth look at npm, Node.js modules, and the working of Grunt plugins
  • Get familiar with installing Grunt and setting up your first Grunt build environment
  • Gain insight on the methods of configuring Grunt and when each method should be used
  • Effectively execute Grunt through the use of task arguments, task aliasing, multi-task targets, and more
  • Construct your own Grunt tasks, multi-tasks, and asynchronous tasks

Publisher resources

Download Example Code

Table of contents

  1. Getting Started with Grunt: The JavaScript Task Runner
    1. Table of Contents
    2. Getting Started with Grunt: The JavaScript Task Runner
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Code examples
      6. Reader feedback
      7. Customer support
        1. Errata
        2. Piracy
        3. Questions
    8. 1. Introducing Grunt
      1. What is Grunt?
      2. Why use Grunt?
      3. Benefits of Grunt
        1. Efficiency
        2. Consistency
        3. Effectiveness
        4. Community
        5. Flexibility
      4. Real-world use cases
        1. Static analysis or Linting
        2. Transcompilation
          1. CoffeeScript
            1. Jade
            2. Stylus
            3. Haml, Sass, and LESS
      5. Minification
      6. Concatenation
      7. Deployment
        1. FTP
        2. SFTP
        3. S3
      8. Summary
    9. 2. Setting Up Grunt
      1. Installation
        1. Node.js
        2. Modules
        3. npm
          1. Finding modules
          2. Installing modules
        4. Grunt
      2. Project setup
        1. package.json
        2. Gruntfile.js
        3. Directory structure
      3. Configuring tasks
        1. Configuring multitasks
        2. Configuring options
        3. Configuring files
          1. Single set of source files
          2. Multiple sets of source files
          3. Mapping a source directory to destination directory
        4. Templates
      4. Summary
    10. 3. Using Grunt
      1. Creating your own tasks
        1. Tasks
          1. The task object
          2. Task aliasing
        2. Multitasks
          1. The multitask object
        3. Asynchronous tasks
      2. Running tasks
        1. Command-line
          1. Task arguments
          2. Runtime options
          3. Task help
        2. Programmatically
        3. Automatically
      3. Using third-party tasks
        1. Searching for tasks
        2. Official versus user tasks
        3. Task popularity
        4. Task features
        5. Task stars
      4. Summary
    11. 4. Grunt in Action
      1. Creating the build
        1. Step 1 – initial directory setup
        2. Step 2 – initial configuration
        3. Step 3 – organizing our source files
          1. Scripts
          3. Styles
        4. Step 4 – optimizing our build files
          1. Scripts
          2. Styles
        5. Step 5 – tasks and options
        6. Step 6 – improving development flow
        7. Step 7 – deploying our application
      2. Summary
    12. 5. Advanced Grunt
      1. Testing with Grunt
      2. Continuous integration with Grunt
      3. External tasks
      4. Grunt plugins
        1. Useful plugins
      5. JavaScript resources
      6. Development tools
        1. Author picks
          1. Mac OS X
          2. Sublime Text
          3. SourceTree
          4. Chrome DevTools
        2. Community picks
          1. WebStorm
          2. Yeoman
      7. Summary
    13. Index

Product information

  • Title: Getting Started with Grunt: The JavaScript Task Runner
  • Author(s):
  • Release date: February 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781783980628