Socket
Socket
Sign inDemoInstall

esbuild-plugin-imagemin

Package Overview
Dependencies
202
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    esbuild-plugin-imagemin

An esbuild plugin for minimizing images using imagemin


Version published
Maintainers
1
Created

Readme

Source

esbuild-plugin-imagemin

An esbuild plugin for minimizing images using imagemin

Install

yarn add -D esbuild-plugin-imagemin
# or
npm install --save-dev esbuild-plugin-imagemin

Usage

const esbuild = require("esbuild");
const imageminPlugin = require("esbuild-plugin-imagemin");

esbuild.build({
  plugins: [imageminPlugin()],
});

ESM import is also included.

The plugin works with png, jpg, gif and svg.

By default this plugin uses:

Configuration

interface ImageminPluginOptions {
  disableDefaultPlugins?: {
    mozjpeg?: boolean,
    pngquant?: boolean,
    svgo?: boolean,
    gifsicle?: boolean,
  };
  defaultPluginsOptions?: {
    mozjpeg?: mozjpeg.Options,
    pngquant?: pngquant.Options,
    svgo?: svgo.Options,
    gifsicle?: gifsicle.Options,
  };
  plugins?: Array<(input: Buffer) => Promise<Buffer>>;
}

disableDefaultPlugins

You can disable some(or even all) of default plugins by passing their names inside disableDefaultPlugins with true value

// only svgo and pngquant will work
esbuild.build({
  plugins: [
    imageminPlugin({
      disableDefaultPlugins: {
        mozjpeg: true,
        gifsicle: true,
      },
    }),
  ],
});

defaultPluginsOptions

You can pass options inside default plugins. You can find the options format in plugins documentation.

esbuild.build({
  plugins: [
    imageminPlugin({
      defaultPluginsOptions: {
        mozjpeg: {
          quality: 50,
        },
      },
    }),
  ],
});

plugins

You can pass any other imagemin plugins with options

const imageminOptipng = require("imagemin-optipng");

esbuild.build({
  plugins: [
    imageminPlugin({
      plugins: [imageminOptipng({ optimizationLevel: 5 })],
    }),
  ],
});

Keywords

FAQs

Last updated on 23 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc