Skip to content

Commit 0a7cc94

Browse files
feat: added built-in typescript types
1 parent c946d50 commit 0a7cc94

16 files changed

+839
-341
lines changed

README.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Using supported `devtool` values enable source map generation.
6060
| :---------------------------------------: | :-----------------------------------------------------------------------------: | :-------------------------------------------------------------: | :--------------------------------------------------------------------------- |
6161
| **[`test`](#test)** | `String\|RegExp\|Array<String\|RegExp>` | `/\.m?js(\?.*)?$/i` | Test to match files against. |
6262
| **[`include`](#include)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to include. |
63-
| **[`exclude`](#)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
63+
| **[`exclude`](#exclude)** | `String\|RegExp\|Array<String\|RegExp>` | `undefined` | Files to exclude. |
6464
| **[`parallel`](#parallel)** | `Boolean\|Number` | `true` | Use multi-process parallel running to improve the build speed. |
65-
| **[`minify`](#minify)** | `Function` | `undefined` | Allows you to override default minify function. |
65+
| **[`minify`](#minify)** | `Function` | `TerserPlugin.terserMinify` | Allows you to override default minify function. |
6666
| **[`terserOptions`](#terseroptions)** | `Object` | [`default`](https://github.com/terser-js/terser#minify-options) | Terser [minify options](https://github.com/terser-js/terser#minify-options). |
6767
| **[`extractComments`](#extractcomments)** | `Boolean\|String\|RegExp\|Function<(node, comment) -> Boolean\|Object>\|Object` | `true` | Whether comments shall be extracted to a separate file. |
6868

@@ -185,7 +185,7 @@ module.exports = {
185185
### `minify`
186186

187187
Type: `Function`
188-
Default: `undefined`
188+
Default: `TerserPlugin.terserMinify`
189189

190190
Allows you to override default minify function.
191191
By default plugin uses [terser](https://github.com/terser-js/terser) package.
@@ -637,6 +637,53 @@ module.exports = {
637637
};
638638
```
639639

640+
### Typescript
641+
642+
With default terser minify function:
643+
644+
```ts
645+
module.exports = {
646+
optimization: {
647+
minimize: true,
648+
minimizer: [
649+
new TerserPlugin({
650+
terserOptions: {
651+
compress: true,
652+
},
653+
}),
654+
],
655+
},
656+
};
657+
```
658+
659+
With built-in minify functions:
660+
661+
```ts
662+
import type { SwcMinifyFunction } from "terser-webpack-plugin";
663+
664+
module.exports = {
665+
optimization: {
666+
minimize: true,
667+
minimizer: [
668+
new TerserPlugin<SwcMinifyFunction>({
669+
minify: TerserPlugin.swcMinify,
670+
terserOptions: {
671+
compress: true,
672+
},
673+
}),
674+
675+
// Alternative:
676+
new TerserPlugin<typeof TerserPlugin.swcMinify>({
677+
minify: TerserPlugin.swcMinify,
678+
terserOptions: {
679+
compress: true,
680+
},
681+
}),
682+
],
683+
},
684+
};
685+
```
686+
640687
## Contributing
641688

642689
Please take a moment to read our contributing guidelines if you haven't yet done so.

0 commit comments

Comments
 (0)