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 ofswc.transform()
, for better performance - enable
mangle
by default for better compression rate
This plugin is faster than terser-webpack-plugin's swc mode.
npm i -D swc-minify-webpack-plugin
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,
}),
],
},
};
Type: boolean | object
Default: true
See https://swc.rs/docs/configuration/minification#jscminifycompress
Type: boolean | object
Default: true
See https://swc.rs/docs/configuration/minification#jscminifymangle
Type: object
See https://swc.rs/docs/configuration/minification#jscminifyformat