CLI and Module for Gzip and Brotli Compression

1.2.0 · abandoned · verified Wed Apr 22

gzip-cli is a command-line interface (CLI) and Node.js module designed for compressing files using both Gzip and Brotli algorithms. It provides robust functionality for specifying glob patterns to target files, defining custom output directories, and applying multiple compression extensions (e.g., .gz and .br) in a single command or programmatic call. The package supports ignoring specific file patterns and preserves the original directory structure when outputting compressed files. The current stable version, 1.2.0, was released in December 2020. The project does not adhere to a fixed release cadence. Its key differentiators include comprehensive support for both Gzip and Brotli, dual interfaces for CLI and programmatic usage, and integrated TypeScript types, enhancing developer experience in TypeScript-based projects. It is primarily used in Node.js environments for optimizing static assets during build processes.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates programmatic compression of static assets using Gzip and Brotli, ignoring specific patterns, within an async function.

import { gzip } from 'gzip-cli';

async function compressAssets() {
  try {
    await gzip({
      patterns: ['dist/public/**/*.{html,css,js,svg}'],
      outputExtensions: ['gz', 'br'],
      ignorePatterns: ['**/icons']
    });
    console.log('All specified assets compressed successfully with Gzip and Brotli.');
  } catch (error) {
    console.error('Failed to compress assets:', error);
    // Handle specific compression errors if needed
  }
}

compressAssets();

view raw JSON →