Skip to main content
The image pipeline is a set of open source Node.js scripts that solve a common problem in vibe-coded apps: images served from external URLs (builder CDNs, Unsplash, etc.) that you don’t control. This pipeline downloads those images, compresses them to WebP using Sharp, and replaces all URL references in your source code with local paths — dramatically improving page load times and eliminating dependency on third-party image hosts.
These scripts are open source and reusable in any Node.js project — not just Nometria deployments.

What it does

Three steps, run in sequence:

Installation

Install from npm:
Available on npm as @nometria-ai/img-opt · Source on GitHub
Or copy files into your project’s scripts/ folder manually:
  • scripts/download-images.js
  • scripts/compress-images.js
  • scripts/replace-image-urls.js
  • scripts/images-download-compress-replace.js (orchestrator)
  • scripts/lib/get-config.js
  • scripts/image-assets.config.js (edit this)
If using the npm package, Sharp is listed as a peer dependency — install it alongside:
Add scripts to package.json:

Configuration

Edit scripts/image-assets.config.js:

Usage

Example output

Before (slow — image served from Unsplash CDN):
After (fast — local WebP, served from your own host):

Why WebP?

WebP provides 25–35% smaller file sizes compared to JPEG at equivalent visual quality, and 25–50% smaller than PNG for images with transparency. All modern browsers support WebP. The default quality setting of 82 is a good balance — noticeably smaller than JPEG at 90, with no visible quality difference at screen resolution.

Custom config path

If you want to keep the config outside scripts/:

Integrating into your deploy workflow

Add image optimization as a pre-build step so it runs before every deployment:
Or run it manually when you add new images to your project, rather than on every build (since images don’t change often).

Source files

The package is available on npm and the source is on GitHub. The same scripts are embedded as templates in Nometria-generated projects.