Book Image

Getting Started with Gulp

By : Travis Maynard
Book Image

Getting Started with Gulp

By: Travis Maynard

Overview of this book

<p>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.</p> <p>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.</p> <p>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.</p>
Table of Contents (14 chapters)

Preface

I wrote this book to provide developers with a simple and inviting way to learn about gulp and the tools that are needed to use it. My goal is to keep the content simple and to remain aware of the intimidations that I experienced while learning gulp myself. With this in mind, I wanted to create content that never assumed too much from the reader, but also kept a steady pace for a more experienced reader to keep them engaged and ensure they learn the concepts actively.

What this book covers

Chapter 1, Introducing Gulp, focuses on helping you understand the languages and tools that you will use. You will learn how to use gulp to perform automated tasks for your development projects.

Chapter 2, Getting Started, focuses on getting your local environment set up by installing any software that is needed to move forward. You will learn how to use a command-line interface and take a look at the anatomy of a gulpfile.

Chapter 3, Performing Tasks with Gulp, covers how to create a set of base tasks that you will build upon in the following chapters. These base tasks include concatenation, minification, and preprocessing of your project files.

Chapter 4, Using Node.js Modules for Advanced Tasks, explores when and why to use node.js modules instead of gulp plugins in our tasks. You will learn how to create new tasks to run a static server, keep your project in sync across devices, and take advantage of node.js' module definitions in your client-side code.

Chapter 5, Resolving Issues, covers how to improve your tasks by adding better error handling, ordering your source files, and cleaning up your compiled code. Additionally, you will learn how to set up task dependencies, generate source maps, and use an external configuration file.

What you need for this book

To the follow the instructions in this book, you will need to have a computer running Mac OS X, Linux, or Windows and a code editor, such as Sublime Text or Textmate. You should also have a basic understanding of how to build websites using HTML, CSS, and JavaScript. This book will build on top of these skills and teach you ways to use them to improve your development workflow.

Who this book is for

If you are a developer who is new to build systems and task runners, but have had prior experience with web development and have basic knowledge of HTML, CSS, and JavaScript, this is the book for you. It will guide you 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!

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "In the code, we have added our concat reference."

A block of code is set as follows:

// Styles Task
gulp.task('styles', function() {
return gulp.src('app/css/*.css')
.pipe(plumber())
.pipe(concat('all.css'))
.pipe(myth())
.pipe(gulp.dest('dist'));
});

Any command-line input or output is written as follows:

npm install beeper --save-dev

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your 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://www.packtpub.com/support and register to have the files e-mailed directly to you.

This book contains code examples that feature the latest improvements to the gulp project.

Due to the close proximity between the release of this book and the official release of those features, we have provided an additional code bundle that features examples using version 3.8.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.