Webpack Documentation

This is the official documentation for Webpack, a static module bundler for modern JavaScript applications.

Overview

Webpack is a powerful tool for bundling JavaScript modules. It processes your application, builds a dependency graph, and generates one or more bundles that can be served to the browser.

Webpack Versions

This documentation covers both Webpack 4 and Webpack 5. While the core concepts remain the same, there are significant differences between versions that affect configuration and plugin usage.

Version Comparison

FeatureWebpack 4Webpack 5
Node.js Requirement6.x.x or later10.13.0 or later
** ES Module Support**BasicFull
Persistent CachingRequires pluginBuilt-in
Module FederationNot availableBuilt-in
Asset ModulesRequires loadersBuilt-in

For detailed version comparison, see 1. Introduction.md.

Documentation Structure

DocumentDescription
1. Introduction.mdCore concepts and overview
2. Installation-Guide.mdHow to install and configure Webpack
3. User-Manual.mdComprehensive guide to Webpack features
4. FAQ.mdFrequently asked questions

Quick Start

Installation

# Initialize project
npm init -y

# Install Webpack
npm install webpack webpack-cli --save-dev

Basic Configuration

// webpack.config.js
const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
};

Run Webpack

npx webpack

Core Concepts

Webpack has five core concepts you need to understand:

  1. Entry: Where webpack should start building the dependency graph
  2. Output: Where webpack should emit the bundles
  3. Loaders: How webpack processes non-JavaScript files
  4. Plugins: How to perform a wider range of build tasks
  5. Mode: Set the environment (development, production, or none)

Version-Specific Guides

Webpack 4 Users

If you're using Webpack 4:

Webpack 5 Users

If you're using Webpack 5:

Migration

If you're migrating from Webpack 4 to Webpack 5, see:

  1. 1. Introduction.md - Webpack 4 vs Webpack 5
  2. 2. Installation-Guide.md - Migration Section
  3. 3. User-Manual.md - Migration from Webpack 4 to Webpack 5

Additional Resources

Community

License

This documentation is based on the official Webpack documentation,