Detalhes do pacote

@espcom/esbuild-plugin-compress

npm coverage ![size-es

esbuild, esbuild-plugin, plugin, compress

readme (leia-me)

@espcom/esbuild-plugin-compress

npm coverage size-esm size-cjs

An esbuild plugin that compresses your output files using gzip, brotli, or zstd compression algorithms.

Installation

You can install this plugin via npm:

npm install @espcom/esbuild-plugin-compress

Usage

To use the plugin, import it and add it to your esbuild configuration.

[!WARNING]
Make sure to set write: false in your esbuild configuration, so the plugin can handle file writing after compression.

import esbuild from 'esbuild';
import { pluginCompress } from '@espcom/esbuild-plugin-compress';

esbuild.build({
  entryPoints: ['app.js'],
  bundle: true,
  write: false, // important for now
  outfile: 'out.js',
  plugins: [
    pluginCompress({
      gzip: true,  // Enable gzip compression
      brotli: true,  // Enable brotli compression
      zstd: true,  // Enable zstd compression
      level: 'high',  // Compression level: low, high, max
      extensions: ['.js', '.css']  // File extensions to compress
    })
  ],
});

Options

The plugin accepts the following options:

  • gzip (boolean): Enable gzip compression.
  • brotli (boolean): Enable brotli compression.
  • zstd (boolean): Enable zstd compression.
  • level ('low' | 'high' | 'max'): Set the compression level (low, high, max). Default is max.
  • extensions (Array<'.js' | '.css' | '.svg' | '.json'>): File extensions to compress. Default is ['.js', '.css'].

Compression Levels

The plugin provides three compression levels:

  • low: Fastest compression with lower ratio.
  • high: Balanced compression ratio and speed.
  • max: Highest compression ratio, but slower.

changelog (log de mudanças)

Changelog

1.2.0 (2025-06-06)

Features

  • bump @mongodb-js/zstd to 2.0.1 (6a3fcad)

1.1.0 (2024-10-17)

Features

  • correcting compress levels (ddae2d7)

Bug Fixes

  • @mongodb-js/zstd version (fd71e34)
  • drop @mongodb-js/zstd version (2f3061a)
  • remove unused import (c8126c6)

1.0.1 (2024-09-20)

Bug Fixes

1.0.0 (2024-09-19)

Features

  • compress plugin initial commit (d07b0c8)