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
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dircompare",
"wagoid",
"autocrlf",
"Minifier",
"Rspack"
],
"ignorePaths": [
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ plugins: [
### Minification

If the `minify` option is set to `true` (the default when webpack's `mode` is `'production'`),
the generated HTML will be minified using [html-minifier-terser](https://github.com/DanielRuf/html-minifier-terser)
the generated HTML will be minified using [HTML Minifier Next](https://github.com/j9t/html-minifier-next)
and the following options:

```js
Expand All @@ -378,8 +378,7 @@ and the following options:
}
```

To use custom [html-minifier options](https://github.com/DanielRuf/html-minifier-terser#options-quick-reference)
pass an object to `minify` instead. This object will not be merged with the defaults above.
To use custom [HTML Minifier Next options](https://github.com/j9t/html-minifier-next#options-quick-reference), pass an object to `minify` instead. This object will not be merged with the defaults above.

To disable minification during production mode set the `minify` option to `false`.

Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/192.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[192],{
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[192],{

/***/ 192
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/461.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[461],{
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[461],{

/***/ 591
(module, __unused_webpack_exports, __webpack_require__) {
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/entryA.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ document.body.appendChild(h1);
/******/ return __webpack_require__.O(result);
/******/ }
/******/
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
/******/ var chunkLoadingGlobal = globalThis["webpackChunk"] = globalThis["webpackChunk"] || [];
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
/******/ })();
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/entryB.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ document.body.appendChild(h1);
/******/ return __webpack_require__.O(result);
/******/ }
/******/
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
/******/ var chunkLoadingGlobal = globalThis["webpackChunk"] = globalThis["webpackChunk"] || [];
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
/******/ })();
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/libMath.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(self["webpackChunk"] = self["webpackChunk"] || []).push([[646],{
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[646],{

/***/ 16
(module) {
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/libText.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(self["webpackChunk"] = self["webpackChunk"] || []).push([[209],{
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[209],{

/***/ 631
(module) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="bundle.js"></script>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script defer="defer" src="bundle.js"></script>
<title>Custom insertion example</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/javascript/dist/webpack-5/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<head><script defer="defer" src="bundle.js"></script><link href="styles.css" rel="stylesheet"></head>Hello World from backend2026-01-16T16:38:04.038Z<h2>Partial</h2><img src="55b19870aff2e53d1fb1.png"/>
<head><script defer="defer" src="bundle.js"></script><link href="styles.css" rel="stylesheet"></head>Hello World from backend2026-05-22T11:58:41.192Z<h2>Partial</h2><img src="55b19870aff2e53d1fb1.png"/>
2 changes: 1 addition & 1 deletion examples/pug-loader/dist/webpack-5/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html><head><title>pug demo</title><link rel="icon" href="favicon.ico"><script defer="defer" src="bundle.js"></script><link href="styles.css" rel="stylesheet"></head><body><div id="main"><div class="time"><b>Current time</b><p>1998-12-31T21:00:00.000Z</p></div><img src="#{require('./logo.png')}"></div></body></html>
<!doctype html><html><head><title>pug demo</title><link rel="icon" href="favicon.ico"><script defer="defer" src="bundle.js"></script><link href="styles.css" rel="stylesheet"></head><body><div id="main"><div class="time"><b>Current time</b><p>1998-12-31T23:00:00.000Z</p></div><img src="#{require('./logo.png')}"></div></body></html>
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ class HtmlWebpackPlugin {
typeof this.options.minify === "object"
? this.options.minify
: {
// https://www.npmjs.com/package/html-minifier-terser#options-quick-reference
// https://www.npmjs.com/package/html-minifier-next#options-quick-reference
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: true,
Expand All @@ -926,7 +926,7 @@ class HtmlWebpackPlugin {
};

try {
html = require("html-minifier-terser").minify(html, minifyOptions);
html = require("html-minifier-next").minify(html, minifyOptions);
} catch (e) {
const isParseError = String(e.message).indexOf("Parse Error") === 0;

Expand Down Expand Up @@ -1033,7 +1033,7 @@ class HtmlWebpackPlugin {
const attributes = {};

if (this.options.scriptLoading === "defer") {
attributes.defer = true;
attributes.defer = "defer";
} else if (this.options.scriptLoading === "module") {
attributes.type = "module";
} else if (this.options.scriptLoading === "systemjs-module") {
Expand Down
Loading