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 install -D webpack webpack-cli
yarn add -D webpack webpack-cli
pnpm add -D webpack webpack-cli
Import
// webpack.config.js
module.exports = { entry: './src/index.js' };Quick Example
// 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
| Package | webpack |
| Category | Build Tool |
| Weekly Downloads | 25M+ |
| License | MIT |
| Install | npm install -D webpack webpack-cli |
Related Packages
Vite is a next-generation frontend build tool created by Evan You (creator of Vue.js) that provides …
Rollup is a JavaScript module bundler that compiles small pieces of code into larger, more complex b…
esbuild is an extremely fast JavaScript and TypeScript bundler and minifier written in Go that is 10…
Babel is the standard JavaScript compiler that transforms modern JavaScript and TypeScript syntax in…
Parcel is a zero-configuration web application bundler that provides a fast development experience a…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.