STATIC MODULE BUNDLER
webpack packs many modules into a few bundled assets. Code splitting allows for loading parts of the application on demand — designed for modern JavaScript apps.
npm install webpack webpack-cli --save-dev
yarn add webpack webpack-cli --dev
pnpm add webpack webpack-cli -D
bun add -d webpack webpack-cli
deno add npm:webpack npm:webpack-cli
weekly downloads
GitHub stars
plugins published
current release
CONFIGURATION
A single config file is enough for most projects. Compose loaders and transforms around any input, then reach for plugins when your build needs more control.
From CommonJS and ES modules to CSS, images, JSON, and custom assets—webpack turns source files into a coherent build pipeline.
const path = require('node:path'); module.exports = { entry: './src/index.cjs', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, mode: 'production', };
import path from 'node:path'; export default { entry: './src/index.mjs', output: { filename: 'bundle.js', path: path.resolve(import.meta.dirname, 'dist'), }, mode: 'production', };
import path from 'node:path'; import { Configuration } from 'webpack'; export default { entry: './src/index.ts', output: { filename: 'bundle.js', path: path.resolve(import.meta.dirname, 'dist'), }, mode: 'production', } satisfies Configuration;
WHY WEBPACK
The original module bundler. Used by Vercel, Shopify, GitHub, Microsoft, and most of the modern frontend stack.
Share code across separately-deployed applications at runtime. The micro-frontend pattern, done right.
Split bundles by route, by demand, or by vendor. Load what's needed, when it's needed.
Static analysis of ES modules eliminates dead code in production builds — automatically.
Edit and see the result without losing application state. The fastest feedback loop in JavaScript tooling.
v5's filesystem cache makes warm builds near-instant. Cold builds are 38% faster than v4 on large monorepos.
The largest ecosystem in JavaScript tooling. If a build problem exists, there's a webpack plugin for it.