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
{{ message }}
Repository navigation
Commit 831bc3f
Browse filesBrowse the repository at this point in the historyBrowse files
docs: drop html-webpack-plugin from the guides and reference
The guide series taught HtmlWebpackPlugin and each page carried a note
explaining why it had not moved to the built-in HTML support yet. Webpack
builds pages itself, so the guides now use it and the plugin is no longer
named anywhere outside the migration guide.
output-management makes src/index.html the entry point: the page lists the
scripts it needs, webpack rewrites their URLs to the emitted bundles, and
there is no second list of entry points to keep in sync. development, HMR
and PWA follow that config through, and caching uses output.html since it
keeps a single JavaScript entry. Every build listing in those guides was
regenerated against webpack 5.110.3.
Scripts a page references become chunks of that page, so their names are
generated (__html_<hash>_<n>) rather than taken from entry. That is what
the listings show now, with a note in output-management and caching saying
where the names come from.
/plugins/html-webpack-plugin is removed and redirects to the Native HTML
guide, which documents the plugin's options and their built-in equivalents.
The plugins index links there instead of to the deleted page.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NuWDbcF2jvq7q1r8aEY5V9
Copy file name to clipboardExpand all lines: src/content/configuration/experiments.mdx
+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
@@ -410,7 +410,7 @@ import page from "./page.html";
410
410
document.documentElement.innerHTML= page;
411
411
```
412
412
413
-
W> **This feature is experimental and partial.** Webpack 5.107 implemented the `html-loader` role: importing an HTML file from JS runs its tag references through the webpack pipeline. Since 5.108 a `.html` file can also be used as an entry, and the default `./src` entry resolves to `index.html` when this experiment is enabled (see [HTML as the default entry](#html-as-the-default-entry) below). Full parity with `html-webpack-plugin` is still in progress; the overall effort is tracked in issue [#536](https://github.com/webpack/webpack/issues/536).
413
+
W> **This feature is experimental and partial.** Webpack 5.107 implemented the `html-loader` role: importing an HTML file from JS runs its tag references through the webpack pipeline. Since 5.108 a `.html` file can also be used as an entry, and the default `./src` entry resolves to `index.html` when this experiment is enabled (see [HTML as the default entry](#html-as-the-default-entry) below). Full parity with the plugin-based setups it replaces is still in progress; the overall effort is tracked in issue [#536](https://github.com/webpack/webpack/issues/536).
414
414
415
415
T> The HTML parser can be tuned via [`module.parser.html`](/configuration/module/#moduleparserhtml): use [`sources`](/configuration/module/#moduleparserhtmlsources) to disable or customize URL-attribute extraction, and [`template`](/configuration/module/#moduleparserhtmltemplate) to transform the HTML source before parsing.
Copy file name to clipboardExpand all lines: src/content/configuration/output.mdx
+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
@@ -886,7 +886,7 @@ T> Typically you don't need to change `output.hotUpdateMainFilename`.
886
886
887
887
`boolean = false``object`
888
888
889
-
Generate an HTML file for each non-HTML [entrypoint](/concepts/entry-points/), injecting that entrypoint's initial JS and CSS output chunks (including chunks shared through [`dependOn`](/configuration/entry-context/#dependencies)). This is the part of `html-webpack-plugin`that scaffolds a document around your bundles, built into webpack core. It relies on the experimental HTML support, so enable [`experiments.html`](/configuration/experiments/#experimentshtml).
889
+
Generate an HTML file for each non-HTML [entrypoint](/concepts/entry-points/), injecting that entrypoint's initial JS and CSS output chunks (including chunks shared through [`dependOn`](/configuration/entry-context/#dependencies)). This is the document scaffolding that used to need a separate plugin, built into webpack core. It relies on the experimental HTML support, so enable [`experiments.html`](/configuration/experiments/#experimentshtml).
890
890
891
891
```js
892
892
// webpack.config.js
@@ -1000,7 +1000,7 @@ Where to place injected chunk `<script>` tags (and `<link rel="modulepreload">`
1000
1000
-`'head'`: move them into `<head>`.
1001
1001
-`false`: suppress sibling-chunk injection; entry tags and resource hints remain.
1002
1002
1003
-
Stylesheet `<link>` tags for CSS chunks are not affected: they always land in `<head>` when the page has one, ahead of the first blocking script, or after `defer` / module script tags when there is none (the order `html-webpack-plugin` emits).
1003
+
Stylesheet `<link>` tags for CSS chunks are not affected: they always land in `<head>` when the page has one, ahead of the first blocking script, or after `defer` / module script tags when there is none.
Copy file name to clipboardExpand all lines: src/content/guides/caching.mdx
+45-40Lines changed: 45 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,7 @@ This guide focuses on the configuration needed to ensure files produced by webpa
29
29
30
30
We can use the `output.filename`[substitutions](/configuration/output/#outputfilename) setting to define the names of our output files. Webpack provides a method of templating the filenames using bracketed strings called **substitutions**. The `[contenthash]` substitution will add a unique hash based on the content of an asset. When the asset's content changes, `[contenthash]` will change as well.
31
31
32
-
Let's get our project set up using the example from [getting started](/guides/getting-started) with the `plugins` from [output management](/guides/output-management), so we don't have to deal with maintaining our `index.html` file manually:
33
-
34
-
T> Webpack can generate the page itself with [`output.html`](/configuration/output/#outputhtml) — see [Native HTML](/guides/native-html/). This guide keeps `HtmlWebpackPlugin` because the generated page re-enters the entry's script under an internal chunk name, which would obscure the bundle filenames this guide is about.
32
+
Let's get our project set up using the example from [getting started](/guides/getting-started), letting webpack write the page for us as in [output management](/guides/output-management), so we don't have to deal with maintaining our `index.html` file manually:
35
33
36
34
**project**
37
35
@@ -51,34 +49,38 @@ webpack-demo
51
49
```diff
52
50
import path from 'node:path';
53
51
import { fileURLToPath } from 'node:url';
54
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
[`output.html`](/configuration/output/#outputhtml) writes a document around the entry and injects its chunks, so the page tracks the hashed filenames on every build.
75
+
76
+
T> Webpack builds the page it generated, which means your entry's code is bundled as a chunk of that page and carries a generated chunk name such as `__html_c191ce97_0`. The name is stable across builds — only the `[contenthash]` in the filename moves — and it is what the listings below show in place of `main`.
77
+
76
78
Running our build script, `npm run build`, with this configuration should produce the following output:
77
79
78
80
```bash
79
81
...
80
82
Asset Size Chunks Chunk Names
81
-
main.7e2c49a622975ebd9b7e.js 544 kB 0 [emitted] [big] main
... we can see that all three have. This is because each [`module.id`](/api/module-variables/#moduleid-commonjs) is incremented based on resolving order by default. Meaning when the order of resolving is changed, the IDs will be changed as well. To recap:
260
264
261
-
- The `main` bundle changed because of its new content.
265
+
- The application bundle changed because of its new content.
262
266
- The `vendor` bundle changed because its `module.id` was changed.
263
267
- And, the `runtime` bundle changed because it now contains a reference to a new module.
264
268
@@ -269,20 +273,21 @@ The first and last are expected, it's the `vendor` hash we want to fix. Let's us
269
273
```diff
270
274
import path from 'node:path';
271
275
import { fileURLToPath } from 'node:url';
272
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
0 commit comments