Leanpub Header

Skip to main content

Webpack 2

A Build Tool for Modern JavaScript Applications

Webpack 2 - A Build Tool for Modern JavaScript Applications helps beginner and intermediate users understand and fully utilize the power of Webpack in their projects.

Minimum price

$7.99

$9.99

You pay

$9.99

Author earns

$7.99

Packages

Details
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
About

About

About the Book

In Webpack 2 - A Build Tool for Modern JavaScript Applications we start by creating a sample application containing some of the most common features of a web application, and then use Webpack to serve, cache and optimize the project assets. Each chapter works as a reference for a different topic, meaning the book can be read just as well in or out of order.

Amongst other things, in this guide we'll go through:

  • The difference between module bundlers and task runners
  • How to install Webpack and create our first configuration file
  • How to use the Webpack Dev Server to serve, watch and refresh only the parts of the application that change without having to do a full page reload
  • How to install Babel to be able to utilize ES6 functionality
  • How to use Source Maps to aid in debugging
  • How to split code into smaller bundles and lazy load them only when they're needed
  • How to utilize tree shaking to remove any code that our project doesn't use
  • How to create environment specific configuration so that we can harness the full power of Webpack in both our development and production environments

Although this guide is a complete guide for Webpack that goes from creating a basic configuration all the way to splitting configuration based on unique environment requirements, it is regularly updated with bonus chapters containing tutorials on new and interesting features and plugins as they come out. Some exciting chapters already in the works are:

  • Loading and transpiling TypeScript files
  • Loading and transpiling SASS/LESS stylesheets
  • Creating and running tests with Karma
  • Automatically linting code with JSLint
  • Supporting multiple languages using internationalization
  • Autoprefixing and removing unused styles in CSS
  • Utilizing Web Workers
  • Automatically installing NPM packages simply by requiring them in your code

Packages

Pick Your Package

All packages include the ebook in the following formats: PDF, EPUB, and Web

Single License

Minimum price

Suggested price$9.99

A single copy of the book and all future updates. Includes full access to all code samples.

$7.99

  • Code samples
    Code samples for all chapters

One for your Friend

Minimum price

Suggested price$16.99

Buy two copies, one for yourself and one for a friend. Includes full access to all code samples and free updates for life.

$9.99

  • Code samples
    Code samples for all chapters

This book is also available in the following packages:

  • Team License

    5 licenses to share between yourself and your team mates! Includes code samples and access to all future updates.

    • Code samples
      Code samples for all chapters
    Minimum price
    $24.99
    Suggested price
    $39.99

Author

About the Author

Sha Alibhai

Sha has been a Software Developer for over 18 years with a BSc in Computing from Coventry University in the UK interested predominantly in web and mobile technologies.

Contents

Table of Contents

Book Revision

Get Notified of Updates via Twitter

Conventions Used in This Book

  1. Tip
  2. Info

Module Bundlers vs Task Runners

  1. Task Runners
  2. Module Bundlers
  3. Webpack

Installation and Basic Use

  1. Local vs Global Package
  2. Creating a Project
  3. Running Webpack from the Command Line
  4. Serving the Project

Creating a Webpack Config File

  1. Running Webpack via NPM Scripts

Serve, Watch and Hot Module Replacement

  1. Module Watchers
  2. Live Reload
  3. Hot Module Replacement (HMR)
  4. Note about HMR updates
  5. Note
  6. Creating a Server with Node

Using Babel to Transpile your Code

  1. Installing Babel
  2. Note
  3. Add a .babelrc file
  4. Adding Module Loaders to Webpack Config
  5. webpack.config.js
  6. Testing ES6 features

Adding Source Maps

  1. Comparing Source Maps
  2. Adding a Source Map

Bundling Images, Stylesheets, HTML Templates and Static Assets

  1. Loading Assets with file-loader
  2. Using url-loader to Encode Assets
  3. Loading CSS with style-loader and css-loader
  4. Using ExtractTextPlugin to Create an External Stylesheet
  5. Loading HTML Templates with html-loader
  6. Bundling Static Assets with copy-webpack-plugin

Exposing Libraries on the Global Scope

Bundle and Code Splitting

  1. Bundle Splitting
  2. Getting Visual Feedback with webpack-bundle-analyzer
  3. The Tilde (~) Bitwise Operator
  4. Code Splitting
  5. Viewing the Contents of Bundles with webpack-bundle-analyzer

Tree Shaking and Minifying your Bundle

  1. Testing Tree Shaking
  2. Tree Shaking with Babel
  3. Minifying the Distribution Bundle
  4. Minifying Javascript
  5. Minifying CSS

Creating Different Environments

  1. Webpack Merge
  2. Splitting the Configuration
  3. Setting the Environment
  4. Loading Environment Specific Settings
  5. Default Settings - webpack.default.js
  6. Development Environment Settings - environment.dev.js
  7. Production Enviroment Settings - environment.production.js
  8. Environment Specific Code
  9. Running Webpack for Different Environments

What Next?

  1. Support Webpack
  2. Twitter Influencers
  3. Webpack Tools
  4. Further Reading
  5. Videos
  6. Courses
  7. Webpack Examples
  8. Angular Resources
  9. React Resources
  10. Framework Agnostic Resources

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub