Skip to content

Commit 22f1555

Browse files
committed
docs: fix typos and improve clarity in README.md
1 parent 186a09d commit 22f1555

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

README.md

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
This plugin uses [cssnano](https://cssnano.github.io/cssnano/) to optimize and minify your CSS.
1717

18-
Just like [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin) but more accurate with source maps and assets using query string, allows caching and works in parallel mode.
18+
It serves as a more accurate alternative to [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin), with better support for source maps, assets with query strings, caching, and parallel processing.
1919

2020
## Getting Started
2121

@@ -49,25 +49,26 @@ module.exports = {
4949
module: {
5050
rules: [
5151
{
52-
test: /.s?css$/,
52+
test: /\.s?css$/,
5353
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
5454
},
5555
],
5656
},
5757
optimization: {
5858
minimizer: [
59-
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
60-
// `...`,
59+
// For webpack v5, you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line // `...`,
6160
new CssMinimizerPlugin(),
6261
],
6362
},
6463
plugins: [new MiniCssExtractPlugin()],
6564
};
6665
```
6766

68-
This will enable CSS optimization only in production mode.
67+
> [!NOTE]
68+
>
69+
> This enables CSS optimization only in production mode by default.
6970
70-
If you want to run it also in development set the `optimization.minimize` option to `true`:
71+
To enable it in development mode as well, set the `optimization.minimize` option to `true`:
7172

7273
**webpack.config.js**
7374

@@ -81,20 +82,20 @@ module.exports = {
8182
};
8283
```
8384

84-
And run `webpack` via your preferred method.
85+
Finally, run Webpack using your preferred method.
8586

8687
## Note about source maps
8788

88-
**Works only with `source-map`, `inline-source-map`, `hidden-source-map` and `nosources-source-map` values for the [`devtool`](https://webpack.js.org/configuration/devtool/) option.**
89+
**This plugin works only with `source-map`, `inline-source-map`, `hidden-source-map` and `nosources-source-map` values for the [`devtool`](https://webpack.js.org/configuration/devtool/) option.**
8990

9091
Why? Because CSS support only these source map types.
9192

92-
The plugin respect the [`devtool`](https://webpack.js.org/configuration/devtool/) and using the `SourceMapDevToolPlugin` plugin.
93-
Using supported `devtool` values enable source map generation.
94-
Using `SourceMapDevToolPlugin` with enabled the `columns` option enables source map generation.
93+
The plugin respects the [`devtool`](https://webpack.js.org/configuration/devtool/) setting and uses the `SourceMapDevToolPlugin` internally.
94+
Using a supported `devtool` value enables source map generation.
95+
Enabling the `columns` option in `SourceMapDevToolPlugin` also allows source map generation.
9596

96-
Use source maps to map error message locations to modules (this slows down the compilation).
97-
If you use your own `minify` function please read the `minify` section for handling source maps correctly.
97+
Use source maps to map error message locations to their original modules (note that this may slow down compilation).
98+
If you use your own `minify` function please refer to the `minify` section for correct handling of source maps.
9899

99100
## Options
100101

@@ -103,14 +104,15 @@ If you use your own `minify` function please read the `minify` section for handl
103104
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.css(\?.*)?$/i` | Test to match files against. |
104105
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to include. |
105106
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
106-
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Enable/disable multi-process parallel running. |
107+
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Enable or disable multi-process parallel running. |
107108
| **[`minify`](#minify)** | `Function\|Array<Function>` | `CssMinimizerPlugin.cssnanoMinify` | Allows to override default minify function. |
108109
| **[`minimizerOptions`](#minimizeroptions)** | `Object\|Array<Object>` | `{ preset: 'default' }` | Cssnano optimisations [options](https://cssnano.github.io/cssnano/docs/what-are-optimisations/). |
109-
| **[`warningsFilter`](#warningsfilter)** | `Function<(warning, file, source) -> Boolean>` | `() => true` | Allow to filter css-minimizer warnings. |
110+
| **[`warningsFilter`](#warningsfilter)** | `Function<(warning, file, source) -> Boolean>` | `() => true` | Allows filtering of css-minimizer warnings. |
110111

111112
### `test`
112113

113-
Type: `String|RegExp|Array<String|RegExp>` - default: `/\.css(\?.*)?$/i`
114+
- Type: `String|RegExp|Array<String|RegExp>`
115+
- Default: `/\.css(\?.*)?$/i`
114116

115117
Test to match files against.
116118

@@ -129,8 +131,8 @@ module.exports = {
129131

130132
### `include`
131133

132-
Type: `String|RegExp|Array<String|RegExp>`
133-
Default: `undefined`
134+
- Type: `String|RegExp|Array<String|RegExp>`
135+
- Default: `undefined`
134136

135137
Files to include.
136138

@@ -151,8 +153,8 @@ module.exports = {
151153

152154
### `exclude`
153155

154-
Type: `String|RegExp|Array<String|RegExp>`
155-
Default: `undefined`
156+
- Type: `String|RegExp|Array<String|RegExp>`
157+
- Default: `undefined`
156158

157159
Files to exclude.
158160

@@ -173,18 +175,18 @@ module.exports = {
173175

174176
### `parallel`
175177

176-
Type: `Boolean|Number`
177-
Default: `true`
178+
- Type: `Boolean|Number`
179+
- Default: `true`
178180

179181
Use multi-process parallel running to improve the build speed.
180-
Default number of concurrent runs: `os.cpus().length - 1` or `os.availableParallelism() - 1` (if this function is supported).
182+
The default number of concurrent runs: `os.cpus().length - 1` or `os.availableParallelism() - 1` (if this function is supported).
181183

182184
> ℹ️ Parallelization can speed up your build significantly and is therefore **highly recommended**.
183185
> If a parallelization is enabled, the packages in `minimizerOptions` must be required via strings (`packageName` or `require.resolve(packageName)`). Read more in [`minimizerOptions`](#minimizeroptions)
184186
185187
#### `Boolean`
186188

187-
Enable/disable multi-process parallel running.
189+
Enable or disable multi-process parallel running.
188190

189191
**webpack.config.js**
190192

@@ -203,7 +205,7 @@ module.exports = {
203205

204206
#### `Number`
205207

206-
Enable multi-process parallel running and set number of concurrent runs.
208+
Enable multi-process parallel running and specify the number of concurrent runs.
207209

208210
**webpack.config.js**
209211

@@ -222,12 +224,12 @@ module.exports = {
222224

223225
### `minify`
224226

225-
Type: `Function|Array<Function>`
226-
Default: `CssMinimizerPlugin.cssnanoMinify`
227+
- Type: `Function|Array<Function>`
228+
- Default: `CssMinimizerPlugin.cssnanoMinify`
227229

228-
Allows overriding default minify function.
230+
Overrides the default minify function.
229231
By default, plugin uses [cssnano](https://github.com/cssnano/cssnano) package.
230-
Useful for using and testing unpublished versions or forks.
232+
This is useful when using or testing unpublished versions or forks.
231233

232234
Possible options:
233235

@@ -240,7 +242,7 @@ Possible options:
240242

241243
> [!WARNING]
242244
>
243-
> **Always use `require` inside `minify` function when `parallel` option enabled**.
245+
> **Always use `require` inside `minify` function when `parallel` option is enabled**.
244246
245247
#### `Function`
246248

@@ -288,7 +290,7 @@ module.exports = {
288290
CssMinimizerPlugin.cssnanoMinify,
289291
CssMinimizerPlugin.cleanCssMinify,
290292
async (data, inputMap, minimizerOptions) => {
291-
// To do something
293+
// Custom minifier function
292294
return {
293295
code: `a{color: red}`,
294296
map: `{"version": "3", ...}`,
@@ -305,8 +307,8 @@ module.exports = {
305307

306308
### `minimizerOptions`
307309

308-
Type: `Object|Array<Object>`
309-
Default: `{ preset: 'default' }`
310+
- Type: `Object|Array<Object>`
311+
- Default: `{ preset: 'default' }`
310312

311313
Cssnano optimisations [options](https://cssnano.co/docs/what-are-optimisations/).
312314

@@ -337,7 +339,7 @@ module.exports = {
337339
The function index in the `minify` array corresponds to the options object with the same index in the `minimizerOptions` array.
338340
If you use `minimizerOptions` like object, all `minify` function accept it.
339341

340-
> If a parallelization is enabled, the packages in `minimizerOptions` must be required via strings (`packageName` or `require.resolve(packageName)`). In this case, we shouldn't use `require`/`import`.
342+
> If parallelization is enabled, the packages in `minimizerOptions` must be referenced via strings (`packageName` or `require.resolve(packageName)`). In this case, we shouldn't use `require`/`import`.
341343
342344
```js
343345
module.exports = {
@@ -356,15 +358,15 @@ module.exports = {
356358

357359
##### `processorOptions` (⚠ only cssnano)
358360

359-
Type: `Object`
360-
Default: `{ from: assetName }`
361+
- Type: `Object`
362+
- Default: `{ from: assetName }`
361363

362364
Allows filtering options [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano.
363365
The `parser`,` stringifier` and `syntax` can be either a function or a string indicating the module that will be imported.
364366

365367
> [!WARNING]
366368
>
367-
> **If a function is passed, the `parallel` option must be disabled.**.
369+
> **If any of these options are passed as a function, the `parallel` option must be disabled.**.
368370
369371
```js
370372
import sugarss from "sugarss";
@@ -405,15 +407,15 @@ module.exports = {
405407

406408
### `warningsFilter`
407409

408-
Type: `Function<(warning, file, source) -> Boolean>`
409-
Default: `() => true`
410+
- Type: `Function<(warning, file, source) -> Boolean>`
411+
- Default: `() => true`
410412

411-
Allow filtering css-minimizer warnings (By default [cssnano](https://github.com/cssnano/cssnano)).
412-
Return `true` to keep the warning, a falsy value (`false`/`null`/`undefined`) otherwise.
413+
Filter css-minimizer warnings (By default [cssnano](https://github.com/cssnano/cssnano)).
414+
Return `true` to keep the warning, or a falsy value (`false`/`null`/`undefined`) to suppress it.
413415

414416
> [!WARNING]
415417
>
416-
> The `source` argument will contain `undefined` if you don't use source maps.
418+
> The `source` parameter will be `undefined` unless source maps are enabled.
417419
418420
**webpack.config.js**
419421

@@ -458,7 +460,7 @@ module.exports = {
458460
module: {
459461
rules: [
460462
{
461-
test: /.s?css$/,
463+
test: /\.s?css$/,
462464
use: [
463465
MiniCssExtractPlugin.loader,
464466
{ loader: "css-loader", options: { sourceMap: true } },
@@ -476,7 +478,7 @@ module.exports = {
476478

477479
### Remove all comments
478480

479-
Remove all comments (including comments starting with `/*!`).
481+
Remove all comments, including those starting with `/*!`.
480482

481483
```js
482484
module.exports = {
@@ -564,8 +566,7 @@ module.exports = {
564566

565567
```js
566568
module.exports = {
567-
// Uncomment if you need source maps
568-
// devtool: "source-map",
569+
// devtool: "source-map", // Uncomment for source maps
569570
optimization: {
570571
minimize: true,
571572
minimizer: [
@@ -585,8 +586,7 @@ module.exports = {
585586

586587
```js
587588
module.exports = {
588-
// Uncomment if you need source maps
589-
// devtool: "source-map",
589+
// devtool: "source-map", // Uncomment for source maps
590590
optimization: {
591591
minimize: true,
592592
minimizer: [
@@ -602,7 +602,8 @@ module.exports = {
602602

603603
## Contributing
604604

605-
Please take a moment to read our contributing guidelines if you haven't yet done so.
605+
We welcome all contributions!
606+
If you're new here, please take a moment to review our contributing guidelines.
606607

607608
[CONTRIBUTING](./.github/CONTRIBUTING.md)
608609

0 commit comments

Comments
 (0)