Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Getting Started with Gulp ??? Second Edition
Getting Started with Gulp ??? Second Edition

Getting Started with Gulp ??? Second Edition: Automating web development workflows , Second Edition

Arrow left icon
Profile Icon Maynard
Arrow right icon
Mex$541.99
eBook Apr 2017 132 pages 2nd Edition
eBook
Mex$541.99
Paperback
Mex$676.99
Subscription
Free Trial
Arrow left icon
Profile Icon Maynard
Arrow right icon
Mex$541.99
eBook Apr 2017 132 pages 2nd Edition
eBook
Mex$541.99
Paperback
Mex$676.99
Subscription
Free Trial
eBook
Mex$541.99
Paperback
Mex$676.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Getting Started with Gulp ??? Second Edition

Chapter 2. Getting Started

Before we dive into Gulp, we need to cover some basic information to make sure we get started at the right pace. The most common reason why people end up avoiding build systems such as Gulp is because they have a preconceived idea that the command line is inherently hard and complicated. I know this because I've been there myself. Once I got over my initial hesitation and decided to dedicate some time to understanding the command line, I've been a much happier developer, and I'm sure you will be too.

In addition to learning how to use the command line, we are also going to understand the installation of Node.js and npm. These two tools allow us to run Gulp and manage the Gulp plugins that we will be using in our project.

Finally, we will cover the basics of using npm, and we will use it to install Gulp. This will provide you with all of the necessary knowledge to get comfortable with using the command line to install packages.

Getting comfortable with the command line


Your computer's command line is one of the most powerful tools in your development toolset. If you've never used a command line or if you're still wondering what it even is, don't worry. We are going to take a look at some common commands and patterns that you will use to complete the rest of the book and set you up for future command line usage.

First, we need to discuss the differences between operating systems and their command-line interfaces that we will use. We are going to specifically cover two topics: Terminal on Mac/Linux and PowerShell on Windows.

Mac OS X Terminal: If you're using a Mac (or Linux), Terminal comes preinstalled as a system application. Simply search for it and run the application, and you're all set.

Windows PowerShell: Our Windows setup is a bit different in that we will use an additional application as our command-line interface. Windows PowerShell is a powerful application that will make your command-line experience much...

Command reference


While learning how to use the command line, it is often easy to forget the basic commands that you will need to use, so I've created this simple reference. Go over each of the standard commands that we will be using throughout the book.

We'll start off with the basics, and then I'll show you some neat shortcuts that you can use while setting up your project structure. The commands we are going to cover are ls, cd, mkdir, touch, and ni.

Listing files and folders (ls)

The ls command will allow us to see what our current directory contains. You will use this a lot to see what is inside of your folders and ensure you are in the right location in your filesystem.

For listing files and folders, use the following command:

ls

A screenshot listing files and folders is as follows:

Changing directory/folder (cd)

The cd command stands for change directory. It allows you to navigate through your filesystem. It will accept both a path relative to the directory you are currently in and an absolute...

Creating your project structure


Having learned all of these great new commands, we're now going to use them to scaffold our project folder. First, let's make sure we're all in the same starting directory. For this, use the following command:

cd ~

Note

The ~ is a shortcut for our home directory, which has an absolute location of /Users/Username in the filesystem.

Next, we're going to list out all of the files and folders in this directory to get a quick look at what it contains and ensure we are where we want to be. For listing files and folders, use the following command:

ls

Once you've run this command, your terminal window will respond with a listing of all your files and folders inside the current directory, which is shown as follows:

Next, we're going to create a new folder named gulp-book for our Gulp project to live in. If you would like to create this folder in another directory, now is the time to put your cd and ls commands to good use. Once you have navigated to a directory you are comfortable...

Adding content to the project


After scaffolding our project folders and files, we must add code to our project. Our project is going to be a rather simple one-page HTML website. However, by setting this code up together, it will help us demonstrate the work that is taking place as we run our Gulp tasks in the upcoming chapters.

Keep in mind that these examples will be rather simple, only to reinforce those demonstrations. You are more than welcome to add in any additional code that you would like, but for the sake of simplicity and clarity, the code examples in this book are designed specifically to demonstrate the work our tasks will do to our code.

Note

You can download the example code files from you account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://packtpub.com/support and register to have the files e-mailed directly to you.

Preparing our HTML file

For our index.html file, we just need to provide...

Summary


In this chapter, you learned about how to use a command-line application to navigate a filesystem and create new files and folders. With this newfound knowledge, we scaffolded our project directory that we will use throughout the remainder of the book. In the next chapter, we will dive into the basics of Gulp to better understand how it works in preparation for writing our own gulpfiles.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • •Gain a solid understanding of Gulp and write your own custom tasks from scratch
  • •Discover ways to add additional functionality to improve your tasks
  • •Get up-and-running with new features added to the latest version of Gulp

Description

This book is a hands-on guide to get you up to speed with gulp. You will quickly learn how to install, configure, and run your own build system. It will instill you with the ability to automate several common development tasks to vastly improve your development workflow. This book first demonstrates various Gulp use cases before running through the steps of configuring, running, and customizing Gulp, providing you with core concepts of gulp, node.js, and npm. Diving a bit deeper into the gulp ecosystem, we will discuss when and why to use a node module instead of a gulp plugin. We will also go over a few issues that we can run into while using gulp and learn about ways to work around them to improve your gulp experience. By the end of this book, you will be able to create your very own gulp build from scratch, create and maintain tasks and project builds, and automate your workflow with plugins and custom tasks.

Who is this book for?

This book is targeted at developers who are new to build systems and task runners but who have had prior experience with web development; a basic knowledge of HTML, CSS, and JavaScript is assumed. It guides the reader through the process of using Gulp to automate several common development tasks so that they can save time and focus on what is most important: writing great code.

What you will learn

  • How to use a command-line interface.
  • Learn about Gulp, Node.js, and npm and how they work together.
  • Create a Gulpfile from scratch and implement it into a project.
  • Write basic tasks that will concatenate, minify, compress, and pre-process your files.
  • Write advanced tasks that will run a local server, sync file changes to your browser, and allow you to write client-side JavaScript using ES2015.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 28, 2017
Length: 132 pages
Edition : 2nd
Language : English
ISBN-13 : 9781787285941
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 28, 2017
Length: 132 pages
Edition : 2nd
Language : English
ISBN-13 : 9781787285941
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$12.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 6,500+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$129.99 billed annually
Feature tick icon Unlimited access to Packt's library of 6,500+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$179.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 6,500+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,708.97
Rapid Gulp
Mex$1128.99
Getting Started with Gulp ??? Second Edition
Mex$676.99
Learning D3.js 5 Mapping
Mex$902.99
Total Mex$ 2,708.97 Stars icon
Visually different images

Table of Contents

6 Chapters
Introducing Gulp Chevron down icon Chevron up icon
Getting Started Chevron down icon Chevron up icon
Understanding the Basics of Gulp Chevron down icon Chevron up icon
Performing Tasks with Gulp Chevron down icon Chevron up icon
Creating Advanced Tasks Chevron down icon Chevron up icon
Tips, Tricks, and Resolving Issues Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Modal Close icon
Modal Close icon