Webpack bundles JavaScript, CSS, HTML, WebAssembly, and assets into optimized output for browsers and environments such as Node.js.
Overview
Webpack is a module bundler whose primary role is packaging JavaScript for browsers, while also handling many other static assets through its compilation pipeline. Dependencies are resolved at build time to reduce what ships at runtime.
It supports code splitting into chunks that load asynchronously, loaders for preprocessing sources, and a plugin system for extending behavior. Recent versions can generate HTML and extract CSS by default, letting an HTML entry drive bundling without separate HTML or CSS loaders for basic setups.
Module formats include ES2015+, CommonJS, and AMD, with static analysis on source ASTs. Optimizations cover deduplication, minification, hashing for cache-friendly chunks, and control over initial versus on-demand payloads.
The tool runs as a Node-based CLI, for example via npx webpack in development or production modes, and targets ES5-compliant browsers with optional polyfills for older Promise-dependent APIs.
Key features
- JavaScript and asset module bundling
- Asynchronous code splitting chunks
- Built-in HTML and CSS bundling support
- Loader pipeline for preprocessors
- Plugin-based extensibility
- Production minification and tree shaking
- ESM, CommonJS, and AMD module support
- Development and production CLI modes
Use cases
- Bundling web apps for browser delivery
- Splitting large apps into lazy-loaded chunks
- Building from HTML entry pages
- Preprocessing TypeScript or templates via loaders
- Optimizing deployable frontend assets