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: README.md
+46-16Lines changed: 46 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ This plugin can use 3 tools to optimize and minify your HTML:
19
19
-[`html-minifier-terser`](https://github.com/terser/html-minifier-terser) (by default) - JavaScript-based HTML minifier.
20
20
-[`@minify-html/node`](https://github.com/wilsonzlin/minify-html) - A Rust HTML minifier meticulously optimised for speed and effectiveness, with bindings for other languages.
21
21
22
+
This plugin integrates seamlessly into your Webpack build pipeline to reduce HTML size and improve loading performance.
23
+
22
24
## Getting Started
23
25
24
26
To begin, you'll need to install `html-minimizer-webpack-plugin`:
@@ -137,18 +139,19 @@ module.exports = {
137
139
};
138
140
```
139
141
140
-
This will enable HTML optimization only in production mode.
141
-
If you want to run it also in development set the `optimization.minimize` option to `true`.
142
+
> [!NOTE]
143
+
>
144
+
> HTML will only be minimized in production mode by default. To enable minification in development, explicitly set `optimization.minimize: true`.
142
145
143
-
And run `webpack` via your preferred method.
146
+
Finally, run `webpack`using the method you normally use (e.g., via CLI or an npm script).
144
147
145
148
> [!NOTE]
146
149
>
147
150
> Removing and collapsing spaces in the tools differ (by default).
148
151
>
149
-
> -`@swc/html` - remove and collapse whitespaces only in safe places (for example - around `html` and `body` elements, inside the `head` element and between metadata elements - `<meta>`/`script`/`link`/etc.)
150
-
> -`html-minifier-terser` - always collapse multiple whitespaces to 1 space (never remove it entirely), but you can change it using [`options`](https://github.com/terser/html-minifier-terser#options-quick-reference)
> -`@swc/html` - Remove and collapse whitespaces only in safe places (for example - around `html` and `body` elements, inside the `head` element and between metadata elements - `<meta>`/`script`/`link`/etc.)
153
+
> -`html-minifier-terser` - Always collapse multiple whitespaces to 1 space (never remove it entirely), but you can change it using [`options`](https://github.com/terser/html-minifier-terser#options-quick-reference)
Use multi-process parallel running to improve the build speed.
252
-
Default number of concurrent runs: `os.cpus().length - 1` or `os.availableParallelism() - 1` (if this function is supported).
254
+
Enables multi-process parallelization to improve build performance.
255
+
256
+
- If `true`, uses `os.cpus().length - 1` or `os.availableParallelism() - 1` (if available).
257
+
258
+
- If `number`, sets the number of concurrent workers.
253
259
254
260
> [!NOTE]
255
261
>
256
262
> Parallelization can speed up your build significantly and is therefore **highly recommended**.
257
263
258
264
#### `boolean`
259
265
260
-
Enable/disable multi-process parallel running.
266
+
Enable or disable multi-process parallel running.
261
267
262
268
**webpack.config.js**
263
269
@@ -346,6 +352,8 @@ Useful for using and testing unpublished versions or forks.
346
352
347
353
#### `function`
348
354
355
+
You can define a custom minify function, giving full control over how the HTML is processed.
356
+
349
357
**webpack.config.js**
350
358
351
359
```js
@@ -375,9 +383,11 @@ module.exports = {
375
383
376
384
#### `array`
377
385
378
-
If an array of functions is passed to the `minify` option, the `minimizerOptions` can be an array or an object.
379
-
If `minimizerOptions` is array, the function index in the `minify` array corresponds to the options object with the same index in the `minimizerOptions` array.
380
-
If you use `minimizerOptions` like object, all `minify` function accept it.
386
+
If an array of functions is passed to the `minify` option, the `minimizerOptions` can be either as:
387
+
388
+
- An array; If `minimizerOptions` is array, the function index in the `minify` array corresponds to the options object with the same index in the `minimizerOptions` array.
389
+
390
+
- A single object; If you use `minimizerOptions` like object, all `minify` function accept it.
0 commit comments