webpack

webpack is a highly configurable JavaScript bundler. It takes your modules — JS/TS, CSS, images, fonts — and packs them into optimized bundles the browser can load, applying transforms and optimizations along the way.

Newer tools like Vite offer a faster default experience, but webpack's flexibility keeps it entrenched in mature codebases and complex enterprise pipelines. If you maintain existing apps, you'll meet it; if you're starting fresh, Vite is usually the better default.

TL;DR

Quick Example

A minimal config showing the core pieces — entry, hashed output, a loader, and production mode:

Core Concepts

Performance & Optimization

Comparison: webpack vs Vite

Common Mistakes

Bundling Node-only modules into the browser

Slow builds from over-broad loaders

FAQ

Should I use webpack or Vite for a new project?

Vite, in most cases — faster dev server and far less configuration. Choose webpack when you're maintaining an existing webpack app or need a niche capability that its mature plugin ecosystem uniquely supports.

What's the difference between loaders and plugins?

Loaders transform individual files as they're imported (e.g. compile TypeScript, inline CSS). Plugins hook into the broader build lifecycle to do cross-cutting work (generate the HTML file, define env vars, minify output).

How does code splitting help?

It breaks your bundle into smaller chunks loaded on demand — typically per route — so the initial page downloads and parses less JavaScript. That directly improves load time and interactivity.

Is webpack still relevant?

Yes, in maintenance and complex enterprise contexts. Its share of new projects has dropped to Vite and friends, but its configurability and huge ecosystem keep it widely used.

Related Topics

References