SurviveJS - Webpack 5
From apprentice to master
Webpack, a module bundler, is a powerful tool that helps you to develop complex web applications. "SurviveJS - Webpack" is meant for beginner to intermediate users of the tool that want to understand webpack better.
About
About the Book
"SurviveJS - Webpack 5" has been built around a tutorial during which you develop a complex configuration while covering different facets of webpack. The 34 short chapters and six appendices work as a reference you can use while developing your web applications. The book has been written with webpack 5 in mind.
Even though the book has been designed around webpack, many of the techniques covered go beyond it. You will learn to improve the quality of your code while becoming aware of optimization techniques that help you to deliver more performant web applications.
The book was developed in collaboration with the webpack community, and its structure has evolved accordingly. A third of royalties go to Tobias Koppers, the author of the tool. The writer is a core developer of webpack so by purchasing this book you will support the effort in multiple ways.
The content has been split as below:
- Foreword by Tobias Koppers, the author of webpack
- Preface by Juho Vepsäläinen, the author of the book and a core developer of webpack
- What is Webpack? - Learn what makes webpack tick
- Developing - Set up a development environment on top of webpack
- Styling - Load and manage styles while learning about topics like autoprefixing and eliminating unused CSS
- Loading Assets - Load different asset types and process them
- Building - Write initial build with webpack and learn techniques like bundle and code splitting
- Optimizing - Learn to optimize the build results by minifying, tree shaking, and other techniques
- Output - Understand webpack's output formats, multiple page builds, and module federation
- Techniques - Learn specific techniques related to topics such as testing and consuming packages
- Extending - Extend webpack with loaders and plugins
- Conclusion - Recap core techniques
- Appendices - Learn how webpack compares with other tools, how to set up Hot Module Replacement, troubleshoot webpack
The Leanpub edition comes with a two page PDF cheatsheet that covers the main ideas of webpack in a compact format. It's also available in poster form (single A3, either portrait or landscape). You also get a ~20 page QA PDF where Tobias Koppers, the creator of the tool answers to tough questions.
Feedback
Packages
Pick Your Package
All packages include the ebook in the following formats: PDF, EPUB, and Web
The Book
Minimum price
Suggested price$19.99The book in pdf, epub, mobi. The source code is available at https://github.com/survivejs/webpack.
$19.99
- CheatsheetCheatsheet covering webpack's core ideas.
- QA with Tobias Koppers, the creator of the toolThis brief document (30+) pages contains QA (questions/answers) with Tobias Koppers, the creator of the tool. Read it to gain more insight into webpack and where it's going.
- PostersPosters covering webpack's core ideas. Print in A3 for the best result.
One for a friend too
Minimum price
Suggested price$33.99Get a copy for a friend as well. Includes two copies.
$33.99
- CheatsheetCheatsheet covering webpack's core ideas.
- QA with Tobias Koppers, the creator of the toolThis brief document (30+) pages contains QA (questions/answers) with Tobias Koppers, the creator of the tool. Read it to gain more insight into webpack and where it's going.
- PostersPosters covering webpack's core ideas. Print in A3 for the best result.
This book is also available in the following packages:
One for the team
Get copies for your team mates. Or friends. I don't discriminate. Includes four copies.
- CheatsheetCheatsheet covering webpack's core ideas.
- QA with Tobias Koppers, the creator of the toolThis brief document (30+) pages contains QA (questions/answers) with Tobias Koppers, the creator of the tool. Read it to gain more insight into webpack and where it's going.
- PostersPosters covering webpack's core ideas. Print in A3 for the best result.
- Minimum price
- $63.99
- Suggested price
- $63.99
- Cheatsheet
Author
About the Authors
Jesús Rodríguez Rodríguez
Jesús Rodríguez Rodríguez is a frontend developer who dedicates his time to moderate the official Angular.js IRC channel and he also gives support there.
He spent some time collaborating with organization like AngularUI and he also write in his blog (http://www.angular-tips.com) all about angular.
He also likes to edit / review books, that also includes writing his own books.
Contents
Table of Contents
Foreword
Preface
Introduction
- What is webpack
- How webpack changes the situation
- What will you learn
- How is the book organized
- Who is the book for
- What are the book conventions
- How is the book versioned
- How to get support
- Where to find additional material
- Acknowledgments
What is Webpack
- Webpack relies on modules
- Webpack’s execution process
- Webpack is configuration driven
- Hot Module Replacement
- Asset hashing
- Code splitting
- Webpack 5
- Conclusion
- IDeveloping
1.Getting Started
- 1.1Setting up the project
- 1.2Installing webpack
- 1.3Running webpack
- 1.4Setting up assets
- 1.5Configuring mini-html-webpack-plugin
- 1.6Examining the output
- 1.7Adding a build shortcut
- 1.8Conclusion
2.Development Server
- 2.1Webpack
watchmode - 2.2webpack-dev-server
- 2.3webpack-plugin-serve
- 2.4Accessing development server from the network
- 2.5Polling instead of watching files
- 2.6Making it faster to develop webpack configuration
- 2.7Watching files outside of webpack’s module graph
- 2.8Conclusion
3.Composing Configuration
- 3.1Possible ways to manage configuration
- 3.2Composing configuration by merging
- 3.3Setting up webpack-merge
- 3.4Benefits of composing configuration
- 3.5Configuration layouts
- 3.6Conclusion
- IIStyling
4.Loading Styles
- 4.1Loading CSS
- 4.2Setting up initial CSS
- 4.3PostCSS
- 4.4Using CSS preprocessors
- 4.5Understanding css-loader lookups
- 4.6Conclusion
5.Separating CSS
- 5.1Setting up
MiniCssExtractPlugin - 5.2Managing styles outside of JavaScript
- 5.3Conclusion
6.Eliminating Unused CSS
- 6.1Setting up Tailwind
- 6.2Enabling PurgeCSS
- 6.3Conclusion
7.Autoprefixing
- 7.1Setting up autoprefixing
- 7.2Defining a browserslist
- 7.3Conclusion
- IIILoading Assets
8.Loader Definitions
- 8.1Anatomy of a loader
- 8.2Loader evaluation order
- 8.3Passing parameters to a loader
- 8.4Inline definitions
- 8.5Branching at
useusing a function - 8.6Loading with
infoobject - 8.7Loading based on
resourceQuery - 8.8Loading based on
issuer - 8.9Alternate ways to match files
- 8.10Understanding loader behavior
- 8.11Conclusion
9.Loading Images
- 9.1Integrating images to the project
- 9.2Using
srcsets - 9.3Optimizing images
- 9.4Loading SVGs
- 9.5Loading images dynamically
- 9.6Loading sprites
- 9.7Using placeholders
- 9.8Referencing to images
- 9.9Conclusion
10.Loading Fonts
- 10.1Setting up a loader
- 10.2Using icon fonts
- 10.3Using Google Fonts
- 10.4Manipulating file-loader output path and
publicPath - 10.5Eliminating unused characters
- 10.6Generating font files based on SVGs
- 10.7Conclusion
11.Loading JavaScript
- 11.1Using Babel with webpack configuration
- 11.2Polyfilling features
- 11.3Babel tips
- 11.4Babel plugins
- 11.5Generating differential builds
- 11.6TypeScript
- 11.7WebAssembly
- 11.8Conclusion
- IVBuilding
12.Source Maps
- 12.1Inline source maps and separate source maps
- 12.2Enabling source maps
- 12.3Source map types supported by webpack
- 12.4Inline source map types
- 12.5Separate source map types
- 12.6Other source map options
- 12.7
SourceMapDevToolPluginandEvalSourceMapDevToolPlugin - 12.8Changing source map prefix
- 12.9Extracting source from source maps
- 12.10Source maps on backend
- 12.11Ignoring source map related warnings
- 12.12Using dependency source maps
- 12.13Conclusion
13.Code Splitting
- 13.1Code splitting formats
- 13.2Controlling code splitting on runtime
- 13.3Code splitting in React
- 13.4Disabling code splitting
- 13.5Machine learning driven prefetching
- 13.6Conclusion
14.Bundle Splitting
- 14.1Adding something to split
- 14.2Setting up a
vendorbundle - 14.3Controlling bundle splitting
- 14.4Splitting and merging chunks
- 14.5Bundle splitting at entry configuration
- 14.6Chunk types in webpack
- 14.7Conclusion
15.Tidying Up
- 15.1Cleaning the build directory
- 15.2Attaching a revision to the build
- 15.3Copying files
- 15.4Conclusion
- VOptimizing
16.Minifying
- 16.1Minifying JavaScript
- 16.2Speeding up JavaScript execution
- 16.3Minifying HTML
- 16.4Minifying CSS
- 16.5Compressing bundles
- 16.6Obfuscating output
- 16.7Conclusion
17.Tree Shaking
- 17.1Demonstrating tree shaking
- 17.2Tree shaking on package level
- 17.3Tree shaking with external packages
- 17.4Conclusion
18.Environment Variables
- 18.1The basic idea of
DefinePlugin - 18.2Setting
process.env.NODE_ENV - 18.3Choosing which module to use
- 18.4Conclusion
19.Adding Hashes to Filenames
- 19.1Placeholders
- 19.2Setting up hashing
- 19.3Conclusion
20.Separating a Runtime
- 20.1Extracting a runtime
- 20.2Using records
- 20.3Integrating with asset pipelines
- 20.4Conclusion
21.Build Analysis
- 21.1Configuring webpack
- 21.2Enabling a performance budget
- 21.3Dependency analysis
- 21.4Composition analysis
- 21.5Output plugins
- 21.6Online services
- 21.7Bundle comparison
- 21.8Unused files analysis
- 21.9Duplication analysis
- 21.10Understanding why a module was bundled
- 21.11Conclusion
22.Performance
- 22.1Measuring impact
- 22.2High-level optimizations
- 22.3Low-level optimizations
- 22.4Optimizing rebundling speed during development
- 22.5Webpack 4 performance tricks
- 22.6Conclusion
- VIOutput
23.Build Targets
- 23.1Web targets
- 23.2Node targets
- 23.3Desktop targets
- 23.4Conclusion
24.Multiple Pages
- 24.1Possible approaches
- 24.2Generating multiple pages
- 24.3Progressive web applications
- 24.4Conclusion
25.Server-Side Rendering
- 25.1Setting up Babel with React
- 25.2Setting up a React demo
- 25.3Configuring webpack
- 25.4Setting up a server
- 25.5Open questions
- 25.6Prerendering
- 25.7Conclusion
26.Module Federation
- 26.1Module federation example
- 26.2Adding webpack configuration
- 26.3Implementing the application with React
- 26.4Separating bootstrap
- 26.5Separating header
- 26.6Pros and cons
- 26.7Learn more
- 26.8Conclusion
- VIITechniques
27.Dynamic Loading
- 27.1Dynamic loading with
require.context - 27.2Dynamic paths with a dynamic
import - 27.3Combining multiple
require.contexts - 27.4Dealing with dynamic paths
- 27.5Conclusion
28.Web Workers
- 28.1Setting up a worker
- 28.2Setting up a host
- 28.3Sharing data
- 28.4Other options
- 28.5Conclusion
29.Internationalization
- 29.1i18n with webpack
- 29.2Setting up translations
- 29.3Setting up webpack
- 29.4Setting up application
- 29.5Conclusion
30.Testing
- 30.1Jest
- 30.2Mocking
- 30.3Removing files from tests
- 30.4Conclusion
31.Deploying Applications
- 31.1Deploying with gh-pages
- 31.2Deploying to other environments
- 31.3Resolving
output.publicPathdynamically - 31.4Conclusion
32.Consuming Packages
- 32.1
resolve.alias - 32.2
resolve.modules - 32.3
resolve.extensions - 32.4
resolve.plugins - 32.5Consuming packages outside of webpack
- 32.6Dealing with globals
- 32.7Managing symbolic links
- 32.8Removing unused modules
- 32.9Managing pre-built dependencies
- 32.10Getting insights on packages
- 32.11Conclusion
- VIIIExtending
33.Extending with Loaders
- 33.1Debugging loaders with loader-runner
- 33.2Implementing an asynchronous loader
- 33.3Returning only output
- 33.4Writing files
- 33.5Passing options to loaders
- 33.6Connecting custom loaders with webpack
- 33.7Pitch loaders
- 33.8Caching with loaders
- 33.9Conclusion
34.Extending with Plugins
- 34.1The basic flow of webpack plugins
- 34.2Setting up a development environment
- 34.3Implementing a basic plugin
- 34.4Capturing options
- 34.5Understanding compiler and compilation
- 34.6Writing files through compilation
- 34.7Managing warnings and errors
- 34.8Plugins can have plugins
- 34.9Conclusion
- Conclusion
- General checklist
- Development checklist
- Production checklist
- Conclusion
- Appendices
Comparison of Build Tools
- Task runners
- Script loaders
- Bundlers
- Zero configuration bundlers
- Other Options
- Conclusion
Hot Module Replacement
- Enabling HMR
- Implementing the HMR interface
- Setting WDS entry points manually
- HMR and dynamic loading
- Conclusion
CSS Modules
- CSS Modules through css-loader
- Using CSS Modules with third-party libraries and CSS
- Conclusion
Searching with React
- Implementing search with code splitting
- Conclusion
Troubleshooting
- Module related errors
- DeprecationWarning
- Conclusion
Glossary
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.