Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

swc-minify-webpack-plugin

guoyunhe245.8kApache-2.02.1.3TypeScript support: included

A faster minimizer for webpack based on swc.minify()

webpack, plugin, minify, uglify, optimization, bundle, build, compile, swc, node

readme

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

changelog

Changelog

2.1.3 - 2024-08-22

  • Fixed Buffer data handling

2.1.2 - 2024-03-28

  • Fixed broken source maps

2.1.1 - 2023-05-27

  • Updated README to mention format option

2.1.0 - 2023-04-26

  • Changed license to Apache 2.0

2.0.1 - 2023-04-20

2.0.0 - 2023-02-12

  • BREAKING CHANGE: Changed default export to named export

1.1.1 - 2023-02-11

  • Fixed readme

1.1.0 - 2023-02-11

  • Fixed export types
  • Changed build tools

1.0.0 - 2022-03-23

  • First working version