Skip to content

D1g1talEntr0py/esbuild-plugin-swc-minify

Repository files navigation

esbuild-plugin-swc-minify

esbuild plugin to minify js(x) files using SWC

Install

// if using npm 🤷🏽‍♂️
npm i -D esbuild-plugin-swc-minify

// if using pnpm 😎
pnpm add -D esbuild-plugin-swc-minify

Usage example

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 }) ]
});

Options

When instantiating plugin you can pass an objects with options. This object has SWC official JsMinifyOptions type, see the 'Type Declarations' in JsMinifyOptions