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
+34-24Lines changed: 34 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,9 @@ This plugin uses [terser](https://github.com/terser/terser) to minify/minimize y
17
17
18
18
## Getting Started
19
19
20
-
Webpack v5 comes with the latest `terser-webpack-plugin` out of the box. If you are using Webpack v5 or above and wish to customize the options, you will still need to install `terser-webpack-plugin`. Using Webpack v4, you have to install `terser-webpack-plugin` v4.
20
+
Webpack v5 comes with the latest `terser-webpack-plugin` out of the box.
21
+
If you are using Webpack v5 or above and wish to customize the options, you will still need to install `terser-webpack-plugin`.
22
+
Using Webpack v4, you have to install `terser-webpack-plugin` v4.
21
23
22
24
To begin, you'll need to install `terser-webpack-plugin`:
23
25
@@ -37,7 +39,7 @@ or
37
39
pnpm add -D terser-webpack-plugin
38
40
```
39
41
40
-
Then add the plugin to your `webpack`config. For example:
42
+
Then add the plugin to your `webpack`configuration. For example:
41
43
42
44
**webpack.config.js**
43
45
@@ -52,7 +54,7 @@ module.exports = {
52
54
};
53
55
```
54
56
55
-
And run `webpack` via your preferred method.
57
+
Finally, run `webpack`using the method you normally use (e.g., via CLI or an npm script).
56
58
57
59
## Note about source maps
58
60
@@ -61,7 +63,7 @@ And run `webpack` via your preferred method.
61
63
Why?
62
64
63
65
-`eval` wraps modules in `eval("string")` and the minimizer does not handle strings.
64
-
-`cheap` has not column information and minimizer generate only a single line, which leave only a single mapping.
66
+
-`cheap` has no column information and the minimizer generates only a single line, which leaves only a single mapping.
65
67
66
68
Using supported `devtool` values enable source map generation.
67
69
@@ -167,6 +169,7 @@ type parallel = boolean | number;
167
169
Default: `true`
168
170
169
171
Use multi-process parallel running to improve the build speed.
172
+
170
173
Default number of concurrent runs: `os.cpus().length - 1` or `os.availableParallelism() - 1` (if this function is supported).
171
174
172
175
> **Note**
@@ -175,7 +178,7 @@ Default number of concurrent runs: `os.cpus().length - 1` or `os.availableParall
175
178
176
179
> **Warning**
177
180
>
178
-
> If you use **Circle CI** or any other environment that doesn't provide real available count of CPUs then you need to setup explicitly number of CPUs to avoid `Error: Call retries were exceeded` (see [#143](https://github.com/webpack-contrib/terser-webpack-plugin/issues/143), [#202](https://github.com/webpack-contrib/terser-webpack-plugin/issues/202)).
181
+
> If you use **Circle CI** or any other environment that doesn't provide the real available count of CPUs then you need to explicitly set up the number of CPUs to avoid `Error: Call retries were exceeded` (see [#143](https://github.com/webpack-contrib/terser-webpack-plugin/issues/143), [#202](https://github.com/webpack-contrib/terser-webpack-plugin/issues/202)).
179
182
180
183
#### `boolean`
181
184
@@ -280,7 +283,7 @@ type minify = (
280
283
281
284
Default: `TerserPlugin.terserMinify`
282
285
283
-
Allows you to override default minify function.
286
+
Allows you to override the default minify function.
284
287
By default plugin uses [terser](https://github.com/terser/terser) package.
285
288
Useful for using and testing unpublished versions or forks.
286
289
@@ -444,9 +447,12 @@ type extractComments =
444
447
Default: `true`
445
448
446
449
Whether comments shall be extracted to a separate file, (see [details](https://github.com/webpack/webpack/commit/71933e979e51c533b432658d5e37917f9e71595a)).
447
-
By default extract only comments using `/^\**!|@preserve|@license|@cc_on/i` regexp condition and remove remaining comments.
450
+
451
+
By default, extract only comments using `/^\**!|@preserve|@license|@cc_on/i` RegExp condition and remove remaining comments.
452
+
448
453
If the original file is named `foo.js`, then the comments will be stored to `foo.js.LICENSE.txt`.
449
-
The `terserOptions.format.comments` option specifies whether the comment will be preserved, i.e. it is possible to preserve some comments (e.g. annotations) while extracting others or even preserving comments that have been extracted.
454
+
455
+
The `terserOptions.format.comments` option specifies whether the comment will be preserved - i.e., it is possible to preserve some comments (e.g. annotations) while extracting others, or even preserve comments that have already been extracted.
450
456
451
457
#### `boolean`
452
458
@@ -469,7 +475,7 @@ module.exports = {
469
475
470
476
#### `string`
471
477
472
-
Extract `all` or `some` (use `/^\**!|@preserve|@license|@cc_on/i` RegExp) comments.
478
+
Extract `all` or `some` (use the `/^\**!|@preserve|@license|@cc_on/i` RegExp) comments.
473
479
474
480
**webpack.config.js**
475
481
@@ -488,7 +494,7 @@ module.exports = {
488
494
489
495
#### `RegExp`
490
496
491
-
All comments that match the given expression will be extracted to the separate file.
497
+
All comments that match the given expression will be extracted to a separate file.
492
498
493
499
**webpack.config.js**
494
500
@@ -507,7 +513,7 @@ module.exports = {
507
513
508
514
#### `function`
509
515
510
-
All comments that match the given expression will be extracted to the separate file.
516
+
All comments that match the given expression will be extracted to a separate file.
511
517
512
518
**webpack.config.js**
513
519
@@ -532,7 +538,7 @@ module.exports = {
532
538
533
539
#### `object`
534
540
535
-
Allow to customize condition for extract comments, specify extracted file name and banner.
541
+
Allows you to customize condition for extracting comments, and specify the extracted file name and banner.
536
542
537
543
**webpack.config.js**
538
544
@@ -581,7 +587,7 @@ type condition =
581
587
|undefined;
582
588
```
583
589
584
-
Condition what comments you need extract.
590
+
The condition that determines which comments should be extracted.
Default: `/*! For license information please see ${commentsFile} */`
659
666
660
-
The banner text that points to the extracted file and will be added on top of the original file.
661
-
Can be `false` (no banner), a `String`, or a `Function<(string) -> String>` that will be called with the filename where extracted comments have been stored.
662
-
Will be wrapped into comment.
667
+
The banner text that points to the extracted file and will be added at the top of the original file.
668
+
669
+
It can be `false` (no banner), a `String`, or a `function<(string) -> String>` that will be called with the filename where the extracted comments have been stored.
670
+
671
+
The banner will be wrapped in a comment.
663
672
664
673
**webpack.config.js**
665
674
@@ -713,7 +722,7 @@ module.exports = {
713
722
714
723
### Remove Comments
715
724
716
-
If you avoid building with comments, use this config:
725
+
If you want to build without comments, use this config:
717
726
718
727
**webpack.config.js**
719
728
@@ -759,11 +768,11 @@ module.exports = {
759
768
760
769
### [`swc`](https://github.com/swc-project/swc)
761
770
762
-
[`swc`](https://github.com/swc-project/swc) is a super-fast compiler written in rust; producing widely-supported javascript from modern standards and typescript.
771
+
[`swc`](https://github.com/swc-project/swc) is a super-fast compiler written in `Rust`, producing widelysupported JavaScript from modern standards and TypeScript.
763
772
764
773
> **Warning**
765
774
>
766
-
> the`extractComments` option is not supported and all comments will be removed by default, it will be fixed in future
775
+
> The`extractComments` option is not supported, and all comments will be removed by default. This will be fixed in future
767
776
768
777
**webpack.config.js**
769
778
@@ -789,7 +798,7 @@ module.exports = {
789
798
790
799
> **Warning**
791
800
>
792
-
> the`extractComments` option is not supported and all legal comments (i.e. copyright, licenses and etc) will be preserved
801
+
> The`extractComments` option is not supported, and all legal comments (i.e. copyright, licenses and etc) will be preserved.
793
802
794
803
**webpack.config.js**
795
804
@@ -818,7 +827,7 @@ module.exports = {
818
827
819
828
### Custom Minify Function
820
829
821
-
Override default minify function - use `uglify-js` for minification.
830
+
Override the default minify function - use `uglify-js` for minification.
822
831
823
832
**webpack.config.js**
824
833
@@ -850,7 +859,7 @@ module.exports = {
850
859
851
860
### Typescript
852
861
853
-
With default terser minify function:
862
+
With default Terser minify function:
854
863
855
864
```ts
856
865
module.exports= {
@@ -912,7 +921,8 @@ module.exports = {
912
921
913
922
## Contributing
914
923
915
-
Please take a moment to read our contributing guidelines if you haven't yet done so.
924
+
We welcome all contributions!
925
+
If you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.
0 commit comments