You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/guides/core-workflows/development/hot-module-replacement.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -203,7 +203,7 @@ try {
203
203
}
204
204
```
205
205
206
-
See the [full documentation of the `webpack-dev-server` Node.js API](#TODO[/api/webpack-dev-server/]).
206
+
See the [full documentation of the `webpack-dev-server` Node.js API](https://github.com/webpack/webpack-dev-server#with-the-api).
207
207
208
208
> [!TIP]
209
209
> If you're [using `webpack-dev-middleware`](/guides/core-workflows/development/#using-webpack-dev-middleware), check out the [`webpack-hot-middleware`](https://github.com/webpack/webpack-hot-middleware) package to enable HMR on your custom dev server.
Copy file name to clipboardExpand all lines: pages/guides/core-workflows/environment-variables.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,14 @@ To distinguish between [development](/guides/core-workflows/development) and [pr
9
9
> [!TIP]
10
10
> webpack's environment variables are different from the [environment variables](https://en.wikipedia.org/wiki/Environment_variable) of operating system shells such as `bash` and `CMD.exe`.
11
11
12
-
The webpack command line [environment option](#TODO[/api/cli/#environment-options])`--env` lets you pass in as many environment variables as you like, and they're then made available in your `webpack.config.js`. For example, `--env production` or `--env goal=local`.
12
+
The webpack command line [environment option](https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md#available-options)`--env` lets you pass in as many environment variables as you like, and they're then made available in your `webpack.config.js`. For example, `--env production` or `--env goal=local`.
13
13
14
14
```bash
15
15
npx webpack --env goal=local --env production --progress
16
16
```
17
17
18
18
> [!TIP]
19
-
> Setting an `env` variable without an assignment, such as `--env production`, sets `env.production` to `true` by default. Other syntaxes are also available. See the [webpack CLI](#TODO[/api/cli/#environment-options]) documentation for more information.
19
+
> Setting an `env` variable without an assignment, such as `--env production`, sets `env.production` to `true` by default. Other syntaxes are also available. See the [webpack CLI](https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md#available-options) documentation for more information.
20
20
21
21
You'll need to make one change to your webpack config. Typically, `export default` points directly to the configuration object. To use the `env` variable, you must make `export default` a function instead:
22
22
@@ -43,4 +43,4 @@ export default env => {
43
43
```
44
44
45
45
> [!TIP]
46
-
> The webpack CLI provides some [built-in environment variables](#TODO[/api/cli/#cli-environment-variables]) that you can access inside a webpack configuration.
46
+
> The webpack CLI provides some [built-in environment variables](https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md#cli-environment-variables) that you can access inside a webpack configuration.
Copy file name to clipboardExpand all lines: pages/guides/core-workflows/output-management.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,7 +216,7 @@ Run `npm run build` again and inspect the `/dist` folder. If everything went wel
216
216
217
217
You might wonder how webpack and its plugins seem to "know" which files are being generated. The answer lies in the manifest that webpack keeps to track how all the modules map to the output bundles. If you're interested in managing webpack's [`output`](#TODO[/configuration/output]) in other ways, the manifest is a good place to start.
218
218
219
-
The manifest data can be extracted into a JSON file for consumption using the [`ManifestPlugin`](#TODO[/plugins/manifest-plugin/]).
219
+
The manifest data can be extracted into a JSON file for consumption using the [`ManifestPlugin`](/docs/api/plugins/ManifestPlugin).
220
220
221
221
We won't walk through a full example of using this plugin in your project, but you can read the [concept page](/guides/getting-started/concepts/manifest) and the [caching guide](/guides/optimization/caching) to learn how this ties into long-term caching.
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/configuration.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Use these capabilities whenever they make sense.
18
18
19
19
The following practices, while technically possible, are best avoided:
20
20
21
-
- Reading CLI arguments directly when using the webpack CLI. Doing so makes your configuration less portable and harder to maintain. Instead, write your own CLI or [use `--env`](#TODO[/api/cli/#env]) to pass environment variables.
21
+
- Reading CLI arguments directly when using the webpack CLI. Doing so makes your configuration less portable and harder to maintain. Instead, write your own CLI or [use `--env`](/guides/core-workflows/environment-variables) to pass environment variables.
22
22
- Exporting non-deterministic values. Running webpack twice should always produce the same output files.
23
23
- Writing long configurations. Split a large configuration into multiple files instead.
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/hot-module-replacement.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,11 +42,11 @@ HMR is an opt-in feature that only affects modules containing HMR code. One exam
42
42
43
43
Similarly, by implementing the HMR interface in a module, you can describe what should happen when that module is updated. In most cases, however, you do not need to write HMR code in every module. If a module has no HMR handlers, the update bubbles up. This means a single handler can update a whole module tree. When any module in the tree is updated, the entire set of dependencies is reloaded.
44
44
45
-
See the [HMR API page](#TODO[/api/hot-module-replacement]) for details on the `module.hot` interface.
45
+
See the [HMR guide](/guides/core-workflows/development/hot-module-replacement) for details on using the `module.hot` interface.
46
46
47
47
### In the runtime
48
48
49
-
Here things get a bit more technical. If you're not interested in the internals, feel free to skip ahead to the [HMR API page](#TODO[/api/hot-module-replacement]) or the [HMR guide](/guides/core-workflows/development/hot-module-replacement).
49
+
Here things get a bit more technical. If you're not interested in the internals, feel free to skip ahead to the [HMR guide](/guides/core-workflows/development/hot-module-replacement).
50
50
51
51
For the module system runtime, additional code is emitted to track each module's `parents` and `children`. On the management side, the runtime supports two methods: `check` and `apply`.
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/loaders.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ export default {
69
69
70
70
### Inline
71
71
72
-
You can specify loaders directly in an `import` statement, or in any [equivalent "importing" method](#TODO[/api/module-methods]). Separate loaders from the resource with `!`. Each part is resolved relative to the current directory.
72
+
You can specify loaders directly in an `import` statement, or in any equivalent "importing" method. Separate loaders from the resource with `!`. Each part is resolved relative to the current directory.
73
73
74
74
> [!TIP]
75
75
> The `loader1!loader2!./file` syntax is shown here only for illustration. In most projects, prefer configuring loaders via `module.rules` and importing styles for their side effects (for example, `import "./styles.css"`).
@@ -119,4 +119,4 @@ Loaders let you customize the output through their preprocessing functions. This
119
119
120
120
Loaders follow the standard [module resolution](/guides/getting-started/concepts/module-resolution). In most cases they are loaded from the [module path](/guides/getting-started/concepts/module-resolution/#module-paths) (think `npm install` and `node_modules`).
121
121
122
-
A loader module is expected to export a function and be written in Node.js-compatible JavaScript. Loaders are most commonly managed with npm, but you can also keep custom loaders as files within your application. By convention, loaders are usually named `xxx-loader` (for example, `json-loader`). See [Writing a Loader](#TODO[/contribute/writing-a-loader/]) for more information.
122
+
A loader module is expected to export a function and be written in Node.js-compatible JavaScript. Loaders are most commonly managed with npm, but you can also keep custom loaders as files within your application. By convention, loaders are usually named `xxx-loader` (for example, `json-loader`).
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/manifest.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The runtime, together with the manifest data, is all the code webpack needs to w
20
20
21
21
Once your application reaches the browser as an `index.html` file, some bundles and a variety of other assets must be loaded and linked together somehow. That `/src` directory you carefully laid out is now bundled, minified, and maybe even split into smaller chunks for lazy-loading by webpack's [`optimization`](#TODO[/configuration/optimization/]). So how does webpack manage the interaction between all of your required modules? This is where the manifest data comes in.
22
22
23
-
As the compiler enters, resolves, and maps out your application, it keeps detailed notes on all of your modules. This collection of data is called the "manifest," and it's what the runtime uses to resolve and load modules once they've been bundled and shipped to the browser. No matter which [module syntax](#TODO[/api/module-methods]) you chose, those `import` and `require` statements have now become `__webpack_require__` methods that point to module identifiers. Using the data in the manifest, the runtime can find out where to retrieve the modules behind those identifiers.
23
+
As the compiler enters, resolves, and maps out your application, it keeps detailed notes on all of your modules. This collection of data is called the "manifest," and it's what the runtime uses to resolve and load modules once they've been bundled and shipped to the browser. No matter which module syntax you chose, those `import` and `require` statements have now become `__webpack_require__` methods that point to module identifiers. Using the data in the manifest, the runtime can find out where to retrieve the modules behind those identifiers.
You can infer the public path from the script tag via `document.currentScript.src` and set it with the [`__webpack_public_path__`](#TODO[/api/module-variables/#__webpack_public_path__-webpack-specific]) module variable at runtime.
234
+
You can infer the public path from the script tag via `document.currentScript.src` and set it with the [`__webpack_public_path__`](/guides/getting-started/concepts/output/#advanced) module variable at runtime.
webpack is a good fit when your application needs a customizable build pipeline: bundling JavaScript modules, processing assets, integrating loaders and plugins, and shaping output for different environments. For a very small page with one or two scripts, a bundler may be unnecessary at first; but for an application with shared dependencies, npm packages, assets, and production builds, webpack gives you explicit control over how everything is assembled.
8
8
9
-
webpack is used to efficiently compile JavaScript modules. Once [installed](/guides/getting-started/installing-webpack), you can interact with webpack through either its [CLI](#TODO[/api/cli]) or its [API](#TODO[/api/node]). If you're new to webpack, please read through the [core concepts](/guides/getting-started/concepts) and [this comparison](#TODO[/comparison]) to learn why you might choose it over the other tools available in the community.
9
+
webpack is used to efficiently compile JavaScript modules. Once [installed](/guides/getting-started/installing-webpack), you can interact with webpack through either its [CLI](https://github.com/webpack/webpack-cli) or its [API](#TODO[/api/node]). If you're new to webpack, please read through the [core concepts](/guides/getting-started/concepts) to learn why you might choose it over the other tools available in the community.
10
10
11
11
> [!WARNING]
12
12
> The examples in this guide use `webpack-cli` 7, which requires Node.js 20.9.0 or later.
@@ -23,7 +23,7 @@ cd webpack-demo
23
23
```
24
24
25
25
> [!TIP]
26
-
> Need a CLI-based project setup or templates? See the [Init command](#TODO[/api/cli/#init]) for webpack's scaffolding flow.
26
+
> Need a CLI-based project setup or templates? See the [Init command](https://github.com/webpack/webpack-cli/tree/main/packages/create-webpack-app) for webpack's scaffolding flow.
27
27
28
28
> [!TIP]
29
29
> This command generates a ready-to-use webpack project with a sensible default configuration. Continue below if you'd like to understand how to set up webpack manually, step by step.
@@ -245,9 +245,9 @@ Open `index.html` from the `dist` directory in your browser, and if everything w
245
245
246
246
The [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) and [`export`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) statements were standardized in [ES2015](https://babeljs.io/docs/en/learn/). They are supported in most browsers today, though some browsers don't recognize the new syntax. Don't worry, though: webpack supports them out of the box.
247
247
248
-
Behind the scenes, webpack analyzes your module graph and bundles the modules into code the browser can load in the right order. It handles module syntax such as `import` and `export`, and supports various other module syntaxes as well. See [Module API](#TODO[/api/module-methods]) for more information.
248
+
Behind the scenes, webpack analyzes your module graph and bundles the modules into code the browser can load in the right order. It handles module syntax such as `import` and `export`, and supports various other module syntaxes as well.
249
249
250
-
Note that webpack will not alter any code other than `import` and `export` statements. If you're using other [ES2015 features](http://es6-features.org/), make sure to [use a transpiler](#TODO[/loaders/#transpiling]) such as [Babel](https://babeljs.io/) via webpack's [loader system](/guides/getting-started/concepts/loaders).
250
+
Note that webpack will not alter any code other than `import` and `export` statements. If you're using other [ES2015 features](http://es6-features.org/), make sure to use a transpiler such as [Babel](https://babeljs.io/) via webpack's [loader system](/guides/getting-started/concepts/loaders).
> Whether to use `--save-dev` depends on your use case. If you use webpack only for bundling, installing it with `--save-dev` is recommended, since you won't include webpack in your production build. Otherwise, you can omit `--save-dev`.
29
29
30
-
If you're using webpack v4 or later and want to call `webpack` from the command line, you'll also need to install the [CLI](#TODO[/api/cli/]):
30
+
If you're using webpack v4 or later and want to call `webpack` from the command line, you'll also need to install the [CLI](https://github.com/webpack/webpack-cli#how-to-install):
0 commit comments