Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 772 Bytes

README.md

File metadata and controls

35 lines (27 loc) · 772 Bytes

ImgMin

Simple Image optimizer (use sharp, svgo)

// usage

import ImgMin from './ImgMin.mjs';

const data = {
  src: ['./src/**/*.{jpg,jpeg,png,svg}', '!**/_*/**'],
  dest: './dist',
  option: {
    base: './src', // base path
    cacheDir: './.cache/images', // cache directory
    isOriginOutput: true, // original format compress enable
    format: ['webp','avif'], // modern format 'webp','avif'

    // Sharp Output options
    // https://sharp.pixelplumbing.com/api-output
    png: { quality: 80 },
    jpg: { quality: 80 },
    webp: { quality: 80, smartSubsample: true },
    avif: { quality: 80 },
  },

  // Custom options by files
  custom: {
    './src/img.png': { webp: { lossless: false, nearLossless: true } },
  },
}

new ImgMin(data).run();