esbuild plugin to minify js(x) files using SWC
// if using npm 🤷🏽♂️
npm i -D esbuild-plugin-swc-minify
// if using pnpm 😎
pnpm add -D esbuild-plugin-swc-minify
import * as esbuild from 'esbuild';
import { swcMinify } from 'esbuild-plugin-swc-minify';
esbuild.build({
entryPoints: [ './index.js' ],
outfile: 'dist/index.min.js',
bundle: true,
minify: true,
sourceMap: true,
plugins: [ swcMinify({ ecma: 2022 }) ]
});
When instantiating plugin you can pass an objects with options. This object has SWC official JsMinifyOptions
type, see the 'Type Declarations' in JsMinifyOptions。