O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting Started with Gulp

Book Description

Create powerful automations with gulp to improve the efficiency of your web project workflow

In Detail

Gulp is a fast and powerful JavaScript task runner that is built upon the node.js platform. It allows you to create tasks that can automate common workflow processes. Gulp.js is comparatively new and has been developed keeping in mind the issues that developers have encountered with Grunt.

Getting Started with Gulp introduces you to the world of building and testing JavaScript applications using gulp. This book is a hands-on guide to get you up to speed with gulp. It will instill you with the ability to automate several common development tasks to vastly improve your development workflow. It will get you started with gulp quickly and efficiently, providing you with core concepts of gulp, node.js, and npm.

By the end of this book, you will be able to create your very own gulp environments from scratch, create and maintain tasks and project builds, and automate your workflow with plugins and custom tasks.

What You Will Learn

  • Create files and directories and run applications using the command line
  • Get to know the basics of node.js and npm and how they relate to gulp
  • Write basic tasks that will concatenate, minify, compress, and preprocess your files
  • Understand the internal working and structure of gulpfiles and gulp tasks
  • Install gulp plugins and add them as project dependencies
  • Gain a solid understanding of gulp to write your own custom tasks from scratch
  • Discover ways to add additional functionality to improve your tasks

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 files e-mailed directly to you.

Table of Contents

  1. Getting Started with Gulp
    1. Table of Contents
    2. Getting Started with Gulp
    3. Credits
    4. Foreword
    5. About the Author
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    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. Introducing Gulp
      1. What is gulp?
      2. What is node.js?
      3. Why use gulp?
        1. Project automation
        2. Streams
        3. Code over config
      4. Summary
    10. 2. Getting Started
      1. Getting comfortable with the command line
        1. Command reference
          1. Listing files and folders (ls)
          2. Changing directory/folder (cd)
          3. Making a directory/folder (mkdir)
          4. Creating a file on Mac/Linux (touch)
          5. Creating a file on Windows (ni)
          6. Administrator permissions (sudo)
      2. Creating your project structure
      3. Adding content to the project
        1. Preparing our HTML file
        2. Preparing our CSS
        3. Preparing our JavaScript
        4. Adding images
      4. Installing node.js and npm
        1. Downloading and installing node.js
        2. Verifying the installation
        3. Creating a package.json file
      5. Installing gulp
        1. Locating gulp
        2. Installing gulp locally
        3. Installing gulp globally
      6. Anatomy of a gulpfile
        1. The task() method
        2. The src() method
        3. The watch() method
        4. The dest() method
        5. The pipe() method
        6. The parallel() and series() methods
        7. Including modules/plugins
      7. Writing a task
      8. Reflection
      9. Summary
    11. 3. Performing Tasks with Gulp
      1. Using gulp plugins
      2. The styles task
        1. Installing gulp plugins
        2. Including gulp plugins
        3. Writing the styles task
          1. Other preprocessors
        4. Reviewing the styles task
      3. The scripts task
        1. Installing gulp plugins
        2. Including gulp plugins
        3. Writing the scripts task
        4. Reviewing the scripts task
      4. The images task
        1. Installing gulp plugins
        2. Including gulp plugins
        3. Writing the images task
        4. Reviewing the images task
      5. The watch task
        1. Writing the watch task
        2. Reviewing the watch task
      6. The default task
        1. Writing the default task
        2. Completed gulpfile
        3. Running tasks
          1. Running the default task
          2. Running a single task
        4. Stopping a watch task
      7. Summary
    12. 4. Using Node.js Modules for Advanced Tasks
      1. Why use plain node.js modules?
      2. Static server
        1. Installing modules
        2. Including modules
        3. Writing a server task
      3. BrowserSync
        1. Installing BrowserSync
        2. Including BrowserSync
        3. Writing the BrowserSync task
      4. Browserify
        1. Installing modules
        2. Including modules
        3. Writing the Browserify task
      5. Summary
    13. 5. Resolving Issues
      1. Handling errors
        1. Installing gulp-plumber
        2. Including gulp-plumber
        3. Installing beeper
        4. Including beeper
        5. Writing an error helper function
      2. Source ordering
      3. Project cleanup
        1. Installing the del module
        2. Including the del module
        3. Writing a clean task
      4. External configuration
      5. Task dependencies
      6. Source maps
      7. Installing a source maps plugin
        1. Including a source maps plugin
        2. Adding source maps to the PipeChain task
      8. Summary
    14. A. Key Features and Additional Resources
      1. Chapter 1 – Introducing Gulp
      2. Chapter 2 – Getting Started
      3. Chapter 3 – Performing Tasks with Gulp
      4. Chapter 4 – Using Node.js Modules for Advanced Tasks
      5. Chapter 5 – Resolving Issues
      6. References
        1. Stream-handbook
        2. NodeSchool
        3. Gulp recipes
    15. Index