Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"directory-tree": "^3.6.0",
"directory-tree-webpack-plugin": "^1.0.3",
"duplexer": "^0.1.1",
"eslint": "^9.39.2",
"eslint": "^9.39.4",
"eslint-config-webpack": "^4.9.3",
"eslint-plugin-cypress": "^6.1.0",
"eslint-plugin-mdx": "^3.6.2",
Expand All @@ -133,7 +133,7 @@
"mdast-util-to-string": "^4.0.0",
"mini-css-extract-plugin": "^2.10.1",
"mkdirp": "^3.0.1",
"npm-run-all": "^4.1.1",
"npm-run-all": "^4.1.5",
"postcss": "^8.5.8",
"postcss-loader": "^8.2.0",
"prettier": "^3.8.1",
Expand Down
24 changes: 24 additions & 0 deletions src/content/api/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ contributors:
- tbroadley
---

<div className="my-8 p-6 bg-orange-50 border-l-8 border-orange-700 rounded-lg text-orange-950 text-sm leading-relaxed">
<h3 className="mt-0 text-orange-700 text-xl font-bold">
API Reference Overview
</h3>
<p className="mb-4">
The webpack API provides a set of low-level interfaces to interact with the
compiler. This is intended for advanced users and plugin/loader developers.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Compiler API:</span> For external control over the webpack
execution.
</li>
<li>
<span className="font-bold">Internal Hooks:</span> Access the tapping system used by
plugins.
</li>
<li>
<span className="font-bold">Stability:</span> Use these interfaces to build custom tooling
on top of webpack.
</li>
</ul>
</div>

A variety of interfaces are available to customize the compilation process.
Some features overlap between interfaces, e.g. a configuration option may be
available via a CLI flag, while others exist only through a single interface.
Expand Down
28 changes: 28 additions & 0 deletions src/content/concepts/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ contributors:
- saishankar404
---

<div className="my-8 p-6 bg-blue-50 border-l-8 border-blue-600 rounded-lg text-slate-900 text-sm leading-relaxed">
<h3 className="mt-0 text-blue-600 text-xl font-bold">
Core Concepts Overview
</h3>
<p className="mb-4">
At its core, <span className="font-bold">webpack</span> is a static module bundler for modern
JavaScript applications. It processes your project and builds a dependency
graph which maps every module your project needs.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Entry:</span> Indicates which module webpack should use to begin
building out its internal dependency graph.
</li>
<li>
<span className="font-bold">Output:</span> Tells webpack where to emit the bundles it
creates and how to name these files.
</li>
<li>
<span className="font-bold">Loaders:</span> Allows webpack to process other types of files
and convert them into valid modules (e.g., CSS, Images, TypeScript).
</li>
<li>
<span className="font-bold">Plugins:</span> Leverages a wide range of tasks like bundle
optimization, asset management, and environment variable injection.
</li>
</ul>
</div>
At its core, **webpack** is a _static module bundler_ for modern JavaScript applications. When webpack processes your application, it internally builds a [dependency graph](/concepts/dependency-graph/) from one or more _entry points_ and then combines every module your project needs into one or more _bundles_, which are static assets to serve your content from.

T> Learn more about JavaScript modules and webpack modules [here](/concepts/modules).
Expand Down
21 changes: 21 additions & 0 deletions src/content/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ contributors:
- chenxsan
---

<div className="my-8 p-6 bg-amber-50 border-l-8 border-amber-600 rounded-lg text-amber-950 text-sm leading-relaxed">
<h3 className="mt-0 text-amber-600 text-xl font-bold">
Configuration Essentials
</h3>
<p className="mb-4">
Webpack's flexibility comes from its <span className="font-bold">configuration-driven</span> nature. While it works out-of-the-box for simple projects, the configuration
file allows you to fine-tune how your assets are processed.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Structure:</span> Typically defined in a <code>webpack.config.js</code> file using CommonJS or ES Modules.
</li>
<li>
<span className="font-bold">Environment:</span> You can export configuration as an object, a function, or multiple configurations for different environments (Dev vs. Prod).
</li>
<li>
<span className="font-bold">Extensibility:</span> It acts as the central hub where you register your Loaders and Plugins.
</li>
</ul>
</div>

Out of the box, webpack won't require you to use a configuration file. However, it will assume the entry point of your project is `src/index.js` and will output the result in `dist/main.js` minified and optimized for production.

Usually, your projects will need to extend this functionality, for this you can create a `webpack.config.js` file in the root folder and webpack will automatically use it.
Expand Down
49 changes: 43 additions & 6 deletions src/content/configuration/optimization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ Webpack runs optimizations for you depending on the chosen [`mode`](/configurati

`boolean`

Tells webpack to check the incompatible types of WebAssembly modules when they are imported/exported. By default `optimization.checkWasmTypes` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise.
Tells webpack to check the incompatible types of WebAssembly modules when they are imported/exported. The default value of `optimization.checkWasmTypes` depends on the [`mode`](/configuration/mode/):

| Mode | Default |
| ------------- | ------- |
| `development` | `false` |
| `production` | `true` |
| `none` | `false` |

**webpack.config.js**

Expand Down Expand Up @@ -106,7 +112,13 @@ export default {
`boolean`

Tells webpack to find segments of the module graph which can be safely concatenated into a single module. Depends on [`optimization.providedExports`](#optimizationprovidedexports) and [`optimization.usedExports`](#optimizationusedexports).
By default `optimization.concatenateModules` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise.
The default value of `optimization.concatenateModules` depends on the [`mode`](/configuration/mode/):

| Mode | Default |
| ------------- | ------- |
| `development` | `false` |
| `production` | `true` |
| `none` | `false` |

**webpack.config.js**

Expand Down Expand Up @@ -150,7 +162,13 @@ Use `optimization.avoidEntryIife` to avoid wrapping the entry module in an IIFE

Currently, `optimization.avoidEntryIife` can only optimize a single entry module along with other modules.

By default, `optimization.avoidEntryIife` is enabled in `production` [mode](/configuration/mode/) and disabled otherwise.
The default value of `optimization.avoidEntryIife` depends on the [`mode`](/configuration/mode/):

| Mode | Default |
| ------------- | ------- |
| `development` | `false` |
| `production` | `true` |
| `none` | `false` |

**webpack.config.js**

Expand All @@ -169,7 +187,13 @@ W> The `optimization.avoidEntryIife` option can negatively affect build performa

`boolean`

Tells webpack to determine and flag chunks which are subsets of other chunks in a way that subsets don’t have to be loaded when the bigger chunk has been already loaded. By default `optimization.flagIncludedChunks` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise.
Tells webpack to determine and flag chunks which are subsets of other chunks in a way that subsets don’t have to be loaded when the bigger chunk has been already loaded. The default value of `optimization.flagIncludedChunks` depends on the [`mode`](/configuration/mode/):

| Mode | Default |
| ------------- | ------- |
| `development` | `false` |
| `production` | `true` |
| `none` | `false` |

**webpack.config.js**

Expand Down Expand Up @@ -205,7 +229,13 @@ export default {

`optimization.mangleExports` allows to control export mangling.

By default `optimization.mangleExports: 'deterministic'` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise.
The default value of `optimization.mangleExports` depends on the [`mode`](/configuration/mode/):

| Mode | Default |
| ------------- | ----------------- |
| `development` | `false` |
| `production` | `'deterministic'` |
| `none` | `false` |

The following values are supported:

Expand Down Expand Up @@ -368,6 +398,7 @@ The default value of `optimization.moduleIds` depends on the [`mode`](/configura
| `development` | `'named'` |
| `production` | `'deterministic'` |
| `none` | `'natural'` |
| `none` | `'natural'` |

The following string values are supported:

Expand Down Expand Up @@ -475,7 +506,13 @@ export default {

`boolean`

Adds an additional hash compilation pass after the assets have been processed to get the correct asset content hashes. If `realContentHash` is set to `false`, internal data is used to calculate the hash and it can change when assets are identical. By default `optimization.realContentHash` is enabled in production [mode](/configuration/mode/) and disabled otherwise.
Adds an additional hash compilation pass after the assets have been processed to get the correct asset content hashes. If `realContentHash` is set to `false`, internal data is used to calculate the hash and it can change when assets are identical. The default value of `optimization.realContentHash` depends on the [`mode`](/configuration/mode/):

| Mode | Default |
| ------------- | ------- |
| `development` | `false` |
| `production` | `true` |
| `none` | `false` |

**webpack.config.js**

Expand Down
23 changes: 23 additions & 0 deletions src/content/guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ contributors:
- benschac
---

<div className="my-8 p-6 bg-green-50 border-l-8 border-green-700 rounded-lg text-green-900 text-sm leading-relaxed">
<h3 className="mt-0 text-green-700 text-xl font-bold">
Guide Roadmap
</h3>
<p className="mb-4">
Whether you're a beginner or a pro, these guides provide step-by-step
instructions for implementing specific features and solving common
development hurdles.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Getting Started:</span> Basic setup for your first bundle.
</li>
<li>
<span className="font-bold">Techniques:</span> Advanced patterns like Code Splitting and
HMR.
</li>
<li>
<span className="font-bold">Best Practices:</span> Performance optimization and security.
</li>
</ul>
</div>

This section contains guides for understanding and mastering the wide variety of tools and features that webpack offers. The first is a guide that takes you through [getting started](/guides/getting-started/).

The guides get more advanced as you go on. Most serve as a starting point, and once completed you should feel more comfortable diving into the actual [documentation](/configuration/).
Expand Down
20 changes: 20 additions & 0 deletions src/content/loaders/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ contributors:
- chenxsan
---

<div className="my-8 p-6 bg-indigo-50 border-l-8 border-indigo-600 rounded-lg text-indigo-950 text-sm leading-relaxed">
<h3 className="mt-0 text-indigo-600 text-xl font-bold">
Understanding Loaders
</h3>
<p className="mb-4">
Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you <code>import</code> or "load" them.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Transformation:</span> Loaders can convert files from a different language (like TypeScript) to JavaScript.
</li>
<li>
<span className="font-bold">Assets:</span> They allow you to include resources like images or CSS directly in your JavaScript dependency graph.
</li>
<li>
<span className="font-bold">Chaining:</span> You can chain multiple loaders together (e.g., <code>sass-loader</code> → <code>css-loader</code> → <code>style-loader</code>).
</li>
</ul>
</div>

Webpack enables use of [loaders](/concepts/loaders) to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js.
Loaders are separate packages that extend webpack's capabilities and are maintained within the broader ecosystem.
Loaders are activated by using `loadername!` prefixes in `import .. from "mod";`/`require()` statements, or are automatically applied via regex from your webpack configuration – see [configuration](/concepts/loaders/#configuration).
Expand Down
25 changes: 25 additions & 0 deletions src/content/migrate/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,29 @@ contributors:
- EugeneHlushko
---

<div className="my-8 p-6 bg-pink-50 border-l-8 border-pink-700 rounded-lg text-pink-950 text-sm leading-relaxed">
<h3 className="mt-0 text-pink-700 text-xl font-bold">
Migration Strategy
</h3>
<p className="mb-4">
Moving between major versions of webpack requires careful planning. This
guide helps you navigate breaking changes and leverage performance
improvements in the latest releases.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Version 5 Focus:</span> Improved build performance through
persistent caching and better tree shaking.
</li>
<li>
<span className="font-bold">Breaking Changes:</span> Learn how to handle deprecated
configuration options and updated internal APIs.
</li>
<li>
<span className="font-bold">Validation:</span> Use this guide as a checklist to ensure your
build remains stable during the transition.
</li>
</ul>
</div>

This section contains information about migrating from older versions of webpack to newer ones.
26 changes: 26 additions & 0 deletions src/content/plugins/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ contributors:
- chenxsan
---

<div className="my-8 p-6 bg-slate-50 border-l-8 border-blue-600 rounded-lg text-slate-900 text-sm leading-relaxed">
<h3 className="mt-0 text-blue-600 text-xl font-bold">
The Power of Plugins
</h3>
<p className="mb-4">
Plugins are the backbone of webpack. They serve the purpose of doing
anything else that a <span className="font-bold">loader</span> cannot do. Webpack itself is
built on the same plugin system that you use in your configuration.
</p>
<ul className="mb-0 list-disc list-inside space-y-2">
<li>
<span className="font-bold">Extensibility:</span> Plugins can hook into the entire
compilation lifecycle to perform complex tasks.
</li>
<li>
<span className="font-bold">Optimization:</span> Use plugins for bundle minification, asset
management, and environment variable injection.
</li>
<li>
<span className="font-bold">Built-in vs Third-party:</span> Webpack provides many internal
plugins (like <code>DefinePlugin</code>), but the community offers
thousands more for specialized needs.
</li>
</ul>
</div>

Webpack has a rich plugin interface. Most of the features within webpack itself use this plugin interface. This makes webpack **flexible**.

| Name | Description |
Expand Down
Loading