Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@srcset/cli

ESM-only package NPM version Node version Dependencies status Install size Build status Coverage status

Command line tool to generate responsive images.

  • 🌠 Resize images for different screen sizes and densities
  • 📸 Convert images to modern formats such as WebP and Avif
  • ⚡️ Powered by sharp
  • 🎯 Glob sources, match rules and srcset.config.js configuration

Install

# pnpm
pnpm add -D @srcset/cli
# yarn
yarn add -D @srcset/cli
# npm
npm i -D @srcset/cli

Usage

npx srcset "src/images/*.jpg" --width 1920,1280,860,320 --format avif,webp,jpg -d static/images

Or with the srcset.config.js configuration file - an ES module, so set "type": "module" in your package.json or pass an .mjs file via --config:

export default {
  src: 'src/images/**/*.jpg',
  dest: 'static/images',
  rules: [
    {
      match: '(min-width: 1920px)',
      width: [1920, 1280, 860, 320],
      format: ['avif', 'webp', 'jpg']
    }
  ]
}

Documentation

For more details, guides and API references, check out the documentation website.