Skip to content

Commit 40f4f55

Browse files
feat: added esbuild minimizer (#426)
1 parent 69e9592 commit 40f4f55

10 files changed

+1160
-643
lines changed

README.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,33 @@ module.exports = {
528528
};
529529
```
530530

531+
### [`uglify-js`](https://github.com/mishoo/UglifyJS)
532+
533+
[`UglifyJS`](https://github.com/mishoo/UglifyJS) is a JavaScript parser, minifier, compressor and beautifier toolkit.
534+
535+
**webpack.config.js**
536+
537+
```js
538+
module.exports = {
539+
optimization: {
540+
minimize: true,
541+
minimizer: [
542+
new TerserPlugin({
543+
minify: TerserPlugin.uglifyJsMinify,
544+
// `terserOptions` options will be passed to `uglify-js`
545+
// Link to options - https://github.com/mishoo/UglifyJS#minify-options
546+
terserOptions: {},
547+
}),
548+
],
549+
},
550+
};
551+
```
552+
531553
### [`swc`](https://github.com/swc-project/swc)
532554

533555
[`swc`](https://github.com/swc-project/swc) is a super-fast compiler written in rust; producing widely-supported javascript from modern standards and typescript.
534556

535-
> ⚠ the `extractComments` option is not supported
557+
> ⚠ the `extractComments` option is not supported and all comments will be removed by default, it will be fixed in future
536558
537559
**webpack.config.js**
538560

@@ -552,9 +574,11 @@ module.exports = {
552574
};
553575
```
554576

555-
### [`uglify-js`](https://github.com/mishoo/UglifyJS)
577+
### [`esbuild`](https://github.com/evanw/esbuild)
578+
579+
[`esbuild`](https://github.com/evanw/esbuild) is an extremely fast JavaScript bundler and minifier.
556580

557-
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit.
581+
> ⚠ the `extractComments` option is not supported and all legal comments (i.e. copyright, licenses and etc) will be preserved
558582
559583
**webpack.config.js**
560584

@@ -564,9 +588,16 @@ module.exports = {
564588
minimize: true,
565589
minimizer: [
566590
new TerserPlugin({
567-
minify: TerserPlugin.uglifyJsMinify,
568-
// `terserOptions` options will be passed to `uglify-js`
569-
// Link to options - https://github.com/mishoo/UglifyJS#minify-options
591+
minify: TerserPlugin.esbuildMinify,
592+
// `terserOptions` options will be passed to `esbuild`
593+
// Link to options - https://esbuild.github.io/api/#minify
594+
// Note: the `minify` options is true by default (and override other `minify*` options), so if you want to disable the `minifyIdentifiers` option (or other `minify*` options) please use:
595+
// terserOptions: {
596+
// minify: false,
597+
// minifyWhitespace: true,
598+
// minifyIdentifiers: false,
599+
// minifySyntax: true,
600+
// },
570601
terserOptions: {},
571602
}),
572603
],

0 commit comments

Comments
 (0)