🔧
Build Tool25M+/wkMIT

webpack

Webpack is a powerful and highly configurable static module bundler for modern JavaScript applications. It processes your application starting from one or more

Installation

npm
npm install -D webpack webpack-cli
yarn
yarn add -D webpack webpack-cli
pnpm
pnpm add -D webpack webpack-cli

Import

ESM
// webpack.config.js
module.exports = { entry: './src/index.js' };

Quick Example

usage
// webpack.config.js
module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: __dirname + '/dist',
  },
  module: {
    rules: [
      { test: /\.tsx?$/, use: 'ts-loader' },
    ],
  },
};

About webpack

Webpack is a powerful and highly configurable static module bundler for modern JavaScript applications. It processes your application starting from one or more entry points, building a dependency graph that includes every module your project needs, then bundles them into one or more output files optimized for the browser. Webpack supports JavaScript, TypeScript, CSS, images, fonts, and any file type through its loader system — loaders transform files as they are added to the dependency graph, enabling TypeScript compilation, Sass processing, image optimization, and more. The plugin system provides hooks into the entire compilation lifecycle for tasks like HTML generation (HtmlWebpackPlugin), code minification (TerserPlugin), CSS extraction, bundle analysis, and environment variable injection. Webpack pioneered code splitting through dynamic imports, enabling lazy loading of application chunks for better performance. Hot Module Replacement (HMR) enables instant updates during development without full page reloads. While Vite and other modern bundlers have become popular for development, Webpack remains the most widely used production bundler, handling complex enterprise build requirements that simpler tools cannot address.

Quick Facts

Packagewebpack
CategoryBuild Tool
Weekly Downloads25M+
LicenseMIT
Installnpm install -D webpack webpack-cli

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.