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.
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.99A single copy of the book and all future updates. Includes full access to all code samples.
$7.99
- Code samplesCode samples for all chapters
One for your Friend
Minimum price
Suggested price$16.99Buy 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 samplesCode 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 samplesCode samples for all chapters
- Minimum price
- $24.99
- Suggested price
- $39.99
- Code samples
Author
About the Author
Contents
Table of Contents
Book Revision
Get Notified of Updates via Twitter
Conventions Used in This Book
- Tip
- Info
Module Bundlers vs Task Runners
- Task Runners
- Module Bundlers
- Webpack
Installation and Basic Use
- Local vs Global Package
- Creating a Project
- Running Webpack from the Command Line
- Serving the Project
Creating a Webpack Config File
- Running Webpack via NPM Scripts
Serve, Watch and Hot Module Replacement
- Module Watchers
- Live Reload
- Hot Module Replacement (HMR)
- Note about HMR updates
- Note
- Creating a Server with Node
Using Babel to Transpile your Code
- Installing Babel
- Note
- Add a .babelrc file
- Adding Module Loaders to Webpack Config
- webpack.config.js
- Testing ES6 features
Adding Source Maps
- Comparing Source Maps
- Adding a Source Map
Bundling Images, Stylesheets, HTML Templates and Static Assets
- Loading Assets with file-loader
- Using url-loader to Encode Assets
- Loading CSS with style-loader and css-loader
- Using ExtractTextPlugin to Create an External Stylesheet
- Loading HTML Templates with html-loader
- Bundling Static Assets with copy-webpack-plugin
Exposing Libraries on the Global Scope
Bundle and Code Splitting
- Bundle Splitting
- Getting Visual Feedback with webpack-bundle-analyzer
- The Tilde (
~) Bitwise Operator - Code Splitting
- Viewing the Contents of Bundles with webpack-bundle-analyzer
Tree Shaking and Minifying your Bundle
- Testing Tree Shaking
- Tree Shaking with Babel
- Minifying the Distribution Bundle
- Minifying Javascript
- Minifying CSS
Creating Different Environments
- Webpack Merge
- Splitting the Configuration
- Setting the Environment
- Loading Environment Specific Settings
- Default Settings - webpack.default.js
- Development Environment Settings - environment.dev.js
- Production Enviroment Settings - environment.production.js
- Environment Specific Code
- Running Webpack for Different Environments
What Next?
- Support Webpack
- Twitter Influencers
- Webpack Tools
- Further Reading
- Videos
- Courses
- Webpack Examples
- Angular Resources
- React Resources
- 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.