setup-srcset
Installation
SKILL.md
Setup srcset
Set up srcset in a project: an image import turns into a tree-shakable module carrying every generated variant, so the app renders a real srcset instead of one fixed file. Variants are encoded with sharp at build time.
import url, { src, srcSet, srcMap, placeholder } from './photo.jpg'
| Export | What it is |
|---|---|
default |
Url of the selected variant, e.g. /assets/photo-BsK7yzuP.jpg |
src |
The selected variant: { id, format, type, width, height, url } |
srcSet |
Every generated variant, as an array |
srcMap |
Id-to-url map, e.g. srcMap.webp600 |
placeholder |
Blur-up data-url, when the placeholder option is on |
Documentation: https://srcset.js.org