biagiojs

Images

images/hero.jpg  →  biagio build  →  dist/img/hero-480w.avif
                                      hero-960w.webp
                                      hero-1440w.jpg

Setup

npm i -D sharp

Put sources in images/. The build generates AVIF + WebP + JPEG variants for each width bucket.

Profiles

ProfileBucketssizesUse
content480, 960, 1440(max-width: 920px) 100vw, 920pxStandard layout
hero480, 960, 1440, 1920100vwFull-bleed hero, LCP
thumb480, 640(max-width: 200px) 120px, 200pxCards, carousel
full640, 1024, 1536, 1920100vwWide galleries
import { smartImage } from 'biagiojs/images';

smartImage(node, {
  src: '/img/hero',
  alt: 'Collection 2026',
  width: 1920,
  height: 1080,
  profile: 'hero',
  aboveFold: true,
  images: site.images,
});

Config

export default {
  site: {
    images: {
      widths: [480, 960, 1440],
      quality: 75,
      bySlug: { hero: [480, 960, 1440, 1920] },
    },
  },
};

Remote images

Download from CDN before the pipeline:

remote: {
  allowedDomains: ['cdn.example.com'],
  sources: [{ url: 'https://cdn.example.com/hero.jpg', slug: 'hero' }],
},

Validation

Post-build, every srcset reference in HTML must exist in dist/img/. Missing files fail the build with page, ref and hint. Examples inside <pre> blocks are ignored.

Dry run

biagio build . --dryRun

Plans buckets without writing files.