Skip to content

Commit

Permalink
feat: added swc minimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Aug 16, 2021
1 parent 72f331d commit 0551a9b
Show file tree
Hide file tree
Showing 8 changed files with 773 additions and 54 deletions.
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ module.exports = {
myCustomOption: true,
},
// Can be async
minify: (file, sourceMap, minimizerOptions) => {
minify: (input, sourceMap, minimizerOptions, extractsComments) => {
// The `minimizerOptions` option contains option from the `terserOptions` option
// You can use `minimizerOptions.myCustomOption`
const extractedComments = [];

// Custom logic for extract comments

const { map, code } = require("uglify-module") // Or require('./path/to/uglify-module')
.minify(file, {
.minify(input, {
/* Your options for minification */
});

Expand Down Expand Up @@ -528,6 +528,30 @@ module.exports = {
};
```

### swc

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

> ⚠ the `extractComments` option is not supported
**webpack.config.js**

```js
module.exports = {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
minify: TerserPlugin.swcMinify,
// `terserOptions` options will be passed to `swc` (`@swc/core`)
// Link to options - https://swc.rs/docs/config-js-minify
terserOptions: {},
}),
],
},
};
```

### Custom Minify Function

Override default minify function - use `uglify-js` for minification.
Expand Down
Loading

0 comments on commit 0551a9b

Please sign in to comment.