swc-minify-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

2.1.3 • Public • Published

SwcMinifyWebpackPlugin

Faster minimizer plugin for webpack based on swc.minify().

This plugin is forked from swc-webpack-plugin, with following differences:

  • Simpiler options
  • Use swc.minify() instead of swc.transform(), for better performance
  • enable mangle by default for better compression rate

This plugin is faster than terser-webpack-plugin's swc mode.

Install

npm i -D swc-minify-webpack-plugin

Usage

Recommended configuration:

// webpack.config.js
const { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new SwcMinifyWebpackPlugin()],
  },
};

Custom configuration:

// webpack.config.js
const { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new SwcMinifyWebpackPlugin({
        compress: false,
        mangle: true,
      }),
    ],
  },
};

Options

compress

Type: boolean | object

Default: true

See https://swc.rs/docs/configuration/minification#jscminifycompress

mangle

Type: boolean | object

Default: true

See https://swc.rs/docs/configuration/minification#jscminifymangle

format

Type: object

See https://swc.rs/docs/configuration/minification#jscminifyformat

Package Sidebar

Install

npm i swc-minify-webpack-plugin

Weekly Downloads

43,338

Version

2.1.3

License

Apache-2.0

Unpacked Size

22.7 kB

Total Files

7

Last publish

Collaborators

  • guoyunhe