Skip to content

Commit d0f87ee

Browse files
committed
docs(en): fetch all
1 parent 66348bb commit d0f87ee

File tree

3 files changed

+31
-53
lines changed

3 files changed

+31
-53
lines changed

src/content/plugins/css-minimizer-webpack-plugin.mdx

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repo: https://github.com/webpack-contrib/css-minimizer-webpack-plugin
2323

2424
This plugin uses [cssnano](https://cssnano.co/) to optimize and minify your CSS.
2525

26-
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 to cache and works in parallel mode.
26+
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.
2727

2828
## Getting Started
2929

@@ -57,6 +57,7 @@ module.exports = {
5757
new CssMinimizerPlugin(),
5858
],
5959
},
60+
plugins: [new MiniCssExtractPlugin()],
6061
};
6162
```
6263

@@ -175,7 +176,7 @@ Default: `true`
175176
Use multi-process parallel running to improve the build speed.
176177
Default number of concurrent runs: `os.cpus().length - 1`.
177178

178-
> ℹ️ Parallelization can speedup your build significantly and is therefore **highly recommended**.
179+
> ℹ️ Parallelization can speed up your build significantly and is therefore **highly recommended**.
179180
> If a parallelization is enabled, the packages in `minimizerOptions` must be required via strings (`packageName` or `require.resolve(packageName)`). Read more in [`minimizerOptions`](#minimizeroptions)
180181
181182
#### `Boolean`
@@ -221,16 +222,17 @@ module.exports = {
221222
Type: `Function|Array<Function>`
222223
Default: `CssMinimizerPlugin.cssnanoMinify`
223224

224-
Allows to override default minify function.
225-
By default plugin uses [cssnano](https://github.com/cssnano/cssnano) package.
225+
Allows overriding default minify function.
226+
By default, plugin uses [cssnano](https://github.com/cssnano/cssnano) package.
226227
Useful for using and testing unpublished versions or forks.
227228

228229
Possible options:
229230

230231
- CssMinimizerPlugin.cssnanoMinify
231232
- CssMinimizerPlugin.cssoMinify
232233
- CssMinimizerPlugin.cleanCssMinify
233-
- `async (data, inputMap, minimizerOptions) => {return {code: "a{color: red}", map: "...", warnings: []}}`
234+
- CssMinimizerPlugin.esbuildMinify
235+
- `async (data, inputMap, minimizerOptions) => {return {code: "a{color: red}", map: "...", warnings: [], errors: []}}`
234236

235237
> ⚠️ **Always use `require` inside `minify` function when `parallel` option enabled**.
236238
@@ -285,6 +287,7 @@ module.exports = {
285287
code: `a{color: red}`,
286288
map: `{"version": "3", ...}`,
287289
warnings: [],
290+
errors: [],
288291
};
289292
},
290293
],
@@ -350,7 +353,7 @@ module.exports = {
350353
Type: `Object`
351354
Default: `{ to: assetName, from: assetName }`
352355

353-
Allows to specify options [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano.
356+
Allows filtering options [`processoptions`](https://postcss.org/api/#processoptions) for the cssnano.
354357
The `parser`,` stringifier` and `syntax` can be either a function or a string indicating the module that will be imported.
355358

356359
> ⚠️ **If a function is passed, the `parallel` option must be disabled.**.
@@ -397,7 +400,7 @@ module.exports = {
397400
Type: `Function<(warning, file, source) -> Boolean>`
398401
Default: `() => true`
399402

400-
Allow to filter css-minimizer warnings (By default [cssnano](https://github.com/cssnano/cssnano)).
403+
Allow filtering css-minimizer warnings (By default [cssnano](https://github.com/cssnano/cssnano)).
401404
Return `true` to keep the warning, a falsy value (`false`/`null`/`undefined`) otherwise.
402405

403406
> ⚠️ The `source` argument will contain `undefined` if you don't use source maps.
@@ -457,6 +460,7 @@ module.exports = {
457460
optimization: {
458461
minimizer: [new CssMinimizerPlugin()],
459462
},
463+
plugins: [new MiniCssExtractPlugin()],
460464
};
461465
```
462466

@@ -485,11 +489,6 @@ module.exports = {
485489

486490
### Using custom minifier [csso](https://github.com/css/csso)
487491

488-
By default plugin uses [cssnano](https://github.com/cssnano/cssnano) package.
489-
It is possible to use another minify function.
490-
491-
> ⚠️ **Always use `require` inside `minify` function when `parallel` option enabled**.
492-
493492
**webpack.config.js**
494493

495494
```js
@@ -499,28 +498,9 @@ module.exports = {
499498
minimize: true,
500499
minimizer: [
501500
new CssMinimizerPlugin({
502-
minify: async (data, inputMap) => {
503-
const csso = require("csso");
504-
const sourcemap = require("source-map");
505-
506-
const [[filename, input]] = Object.entries(data);
507-
const minifiedCss = csso.minify(input, {
508-
filename: filename,
509-
sourceMap: true,
510-
});
511-
512-
if (inputMap) {
513-
minifiedCss.map.applySourceMap(
514-
new sourcemap.SourceMapConsumer(inputMap),
515-
filename
516-
);
517-
}
518-
519-
return {
520-
code: minifiedCss.css,
521-
map: minifiedCss.map.toJSON(),
522-
};
523-
},
501+
minify: CssMinimizerPlugin.cssoMinify,
502+
// Uncomment this line for options
503+
// minimizerOptions: { restructure: false },
524504
}),
525505
],
526506
},
@@ -547,7 +527,7 @@ module.exports = {
547527
};
548528
```
549529

550-
### Using custom minifier [csso](https://github.com/css/csso)
530+
### Using custom minifier [esbuild](https://github.com/evanw/esbuild)
551531

552532
**webpack.config.js**
553533

@@ -558,9 +538,7 @@ module.exports = {
558538
minimize: true,
559539
minimizer: [
560540
new CssMinimizerPlugin({
561-
minify: CssMinimizerPlugin.cssoMinify,
562-
// Uncomment this line for options
563-
// minimizerOptions: { restructure: false },
541+
minify: CssMinimizerPlugin.esbuildMinify,
564542
}),
565543
],
566544
},

src/content/plugins/html-minimizer-webpack-plugin.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Default: `true`
156156
Use multi-process parallel running to improve the build speed.
157157
Default number of concurrent runs: `os.cpus().length - 1`.
158158

159-
> ℹ️ Parallelization can speedup your build significantly and is therefore **highly recommended**.
159+
> ℹ️ Parallelization can speed up your build significantly and is therefore **highly recommended**.
160160
161161
#### `Boolean`
162162

@@ -202,7 +202,7 @@ Type: `Function|Array<Function>`
202202
Default: `HtmlMinimizerPlugin.htmlMinifierTerser`
203203

204204
Allows you to override default minify function.
205-
By default plugin uses [html-minifier-terser](https://github.com/terser/html-minifier-terser) package.
205+
By default, plugin uses [html-minifier-terser](https://github.com/terser/html-minifier-terser) package.
206206
Useful for using and testing unpublished versions or forks.
207207

208208
> ⚠️ **Always use `require` inside `minify` function when `parallel` option enabled**.

src/content/plugins/terser-webpack-plugin.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repo: https://github.com/webpack-contrib/terser-webpack-plugin
2121

2222

2323

24-
This plugin uses [terser](https://github.com/terser-js/terser) to minify/minimize your JavaScript.
24+
This plugin uses [terser](https://github.com/terser/terser) to minify/minimize your JavaScript.
2525

2626
## Getting Started
2727

@@ -63,15 +63,15 @@ Using supported `devtool` values enable source map generation.
6363

6464
## Options
6565

66-
| Name | Type | Default | Description |
67-
| :---------------------------------------: | :-----------------------------------------------------------------------------: | :-------------------------------------------------------------: | :--------------------------------------------------------------------------- |
68-
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.m?js(\?.*)?$/i` | Test to match files against. |
69-
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to include. |
70-
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
71-
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Use multi-process parallel running to improve the build speed. |
72-
| **[`minify`](#minify)** | `Function` | `TerserPlugin.terserMinify` | Allows you to override default minify function. |
73-
| **[`terserOptions`](#terseroptions)** | `Object` | [`default`](https://github.com/terser-js/terser#minify-options) | Terser [minify options](https://github.com/terser-js/terser#minify-options). |
74-
| **[`extractComments`](#extractcomments)** | `Boolean\|String\|RegExp\|Function<(node, comment) -> Boolean\|Object>\|Object` | `true` | Whether comments shall be extracted to a separate file. |
66+
| Name | Type | Default | Description |
67+
| :---------------------------------------: | :-----------------------------------------------------------------------------: | :----------------------------------------------------------: | :------------------------------------------------------------------------ |
68+
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.m?js(\?.*)?$/i` | Test to match files against. |
69+
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to include. |
70+
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
71+
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Use multi-process parallel running to improve the build speed. |
72+
| **[`minify`](#minify)** | `Function` | `TerserPlugin.terserMinify` | Allows you to override default minify function. |
73+
| **[`terserOptions`](#terseroptions)** | `Object` | [`default`](https://github.com/terser/terser#minify-options) | Terser [minify options](https://github.com/terser/terser#minify-options). |
74+
| **[`extractComments`](#extractcomments)** | `Boolean\|String\|RegExp\|Function<(node, comment) -> Boolean\|Object>\|Object` | `true` | Whether comments shall be extracted to a separate file. |
7575

7676
### `test`
7777

@@ -195,7 +195,7 @@ Type: `Function`
195195
Default: `TerserPlugin.terserMinify`
196196

197197
Allows you to override default minify function.
198-
By default plugin uses [terser](https://github.com/terser-js/terser) package.
198+
By default plugin uses [terser](https://github.com/terser/terser) package.
199199
Useful for using and testing unpublished versions or forks.
200200

201201
> ⚠️ **Always use `require` inside `minify` function when `parallel` option enabled**.
@@ -252,9 +252,9 @@ module.exports = {
252252
### `terserOptions`
253253

254254
Type: `Object`
255-
Default: [default](https://github.com/terser-js/terser#minify-options)
255+
Default: [default](https://github.com/terser/terser#minify-options)
256256

257-
Terser [options](https://github.com/terser-js/terser#minify-options).
257+
Terser [options](https://github.com/terser/terser#minify-options).
258258

259259
**webpack.config.js**
260260

0 commit comments

Comments
 (0)