Skip to content

Commit 55a6826

Browse files
authored
docs: fix typos and improve clarity in README.md (#152)
1 parent 04c8a07 commit 55a6826

File tree

1 file changed

+46
-16
lines changed

1 file changed

+46
-16
lines changed

README.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This plugin can use 3 tools to optimize and minify your HTML:
1919
- [`html-minifier-terser`](https://github.com/terser/html-minifier-terser) (by default) - JavaScript-based HTML minifier.
2020
- [`@minify-html/node`](https://github.com/wilsonzlin/minify-html) - A Rust HTML minifier meticulously optimised for speed and effectiveness, with bindings for other languages.
2121

22+
This plugin integrates seamlessly into your Webpack build pipeline to reduce HTML size and improve loading performance.
23+
2224
## Getting Started
2325

2426
To begin, you'll need to install `html-minimizer-webpack-plugin`:
@@ -137,18 +139,19 @@ module.exports = {
137139
};
138140
```
139141

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`.
142145
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).
144147

145148
> [!NOTE]
146149
>
147150
> Removing and collapsing spaces in the tools differ (by default).
148151
>
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)
151-
> - `@minify-html/node` - please read documentation https://github.com/wilsonzlin/minify-html#whitespace
152+
> - `@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)
154+
> - `@minify-html/node` - Please read documentation https://github.com/wilsonzlin/minify-html#whitespace for detailed whitespace behavior.
152155
153156
## Options
154157

@@ -194,7 +197,7 @@ type include = string | RegExp | Array<string | RegExp>;
194197

195198
Default: `undefined`
196199

197-
Files to include.
200+
Files to include for minification.
198201

199202
**webpack.config.js**
200203

@@ -221,7 +224,7 @@ type exclude = string | RegExp | Array<string | RegExp>;
221224

222225
Default: `undefined`
223226

224-
Files to exclude.
227+
Files to exclude from minification.
225228

226229
**webpack.config.js**
227230

@@ -248,16 +251,19 @@ type parallel = undefined | boolean | number;
248251

249252
Default: `true`
250253

251-
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.
253259

254260
> [!NOTE]
255261
>
256262
> Parallelization can speed up your build significantly and is therefore **highly recommended**.
257263
258264
#### `boolean`
259265

260-
Enable/disable multi-process parallel running.
266+
Enable or disable multi-process parallel running.
261267

262268
**webpack.config.js**
263269

@@ -346,6 +352,8 @@ Useful for using and testing unpublished versions or forks.
346352
347353
#### `function`
348354

355+
You can define a custom minify function, giving full control over how the HTML is processed.
356+
349357
**webpack.config.js**
350358

351359
```js
@@ -375,9 +383,11 @@ module.exports = {
375383

376384
#### `array`
377385

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.
381391

382392
**webpack.config.js**
383393

@@ -427,12 +437,28 @@ type minimizerOptions =
427437
}>;
428438
```
429439

430-
Default: `{ caseSensitive: true, collapseWhitespace: true, conservativeCollapse: true, keepClosingSlash: true, minifyCSS: true, minifyJS: true, removeComments: true, removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true, }`
440+
Default:
441+
442+
```js
443+
{
444+
caseSensitive: true,
445+
collapseWhitespace: true,
446+
conservativeCollapse: true,
447+
keepClosingSlash: true,
448+
minifyCSS: true,
449+
minifyJS: true,
450+
removeComments: true,
451+
removeScriptTypeAttributes: true,
452+
removeStyleLinkTypeAttributes: true,
453+
}
454+
```
431455

432456
`Html-minifier-terser` optimizations [options](https://github.com/terser/html-minifier-terser#options-quick-reference).
433457

434458
#### `object`
435459

460+
Applies the same options to the default or custom `minify` function.
461+
436462
```js
437463
module.exports = {
438464
optimization: {
@@ -534,9 +560,12 @@ module.exports = {
534560

535561
HTML Fragments:
536562

563+
Use this for partial HTML files (e.g. inside <template> tags or HTML strings).
564+
537565
```js
538566
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
539567
const CopyPlugin = require("copy-webpack-plugin");
568+
const path = require("path");
540569

541570
module.exports = {
542571
module: {
@@ -619,7 +648,8 @@ You can use multiple `HtmlMinimizerPlugin` plugins to compress different files w
619648

620649
## Contributing
621650

622-
Please take a moment to read our contributing guidelines if you haven't yet done so.
651+
We welcome all contributions!
652+
If you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.
623653

624654
[CONTRIBUTING](./.github/CONTRIBUTING.md)
625655

0 commit comments

Comments
 (0)