[]previous and next page

DuskImageConfig

Image settings: the remote hosts the optimizer may fetch, and the widths, formats and qualities it serves.

Image settings: the remote hosts the optimizer may fetch, and the widths, formats and qualities it serves.

Import#

ts
import type { DuskImageConfig } from "@shadow-js/dusk/vite";

Signature#

ts
interface DuskImageConfig {
  /** Hosts whose images may be optimized (`cdn.example`, `cdn.example:8443`). */
  readonly domains?: readonly string[];
  /** Origins whose images may be optimized (`https://images.example`). Added to `domains`. */
  readonly remotePatterns?: readonly string[];
  /**
   * The widths the optimizer serves: `deviceSizes` (responsive images, `fill`) and `imageSizes` (small fixed images).
   * A list given replaces its default. `<Image>` snaps to these widths, and the server serves exactly them, so an image
   * never asks for a width the optimizer refuses. The largest is the optimizer's maximum width.
   * Default: 640 to 3840 for `deviceSizes`, 32 to 384 for `imageSizes`.
   */
  readonly widths?: ImageWidths;
  /** Same as `widths.deviceSizes`, kept for existing configurations. Not with `widths`. */
  readonly sizes?: readonly number[];
  /** The formats the optimizer may produce. `original` is the source's own. Default: all of them. */
  readonly formats?: readonly ("original" | "webp" | "avif" | "jpeg" | "png")[];
  /** The qualities the optimizer may produce (1 to 100). Default: any. */
  readonly qualities?: readonly number[];
}

Members#

Name Type Description
domains? readonly domains?: readonly string[] Hosts whose images may be optimized (cdn.example, cdn.example:8443).
remotePatterns? readonly remotePatterns?: readonly string[] Origins whose images may be optimized (https://images.example). Added to domains.
widths? readonly widths?: ImageWidths The widths the optimizer serves: deviceSizes (responsive images, fill) and imageSizes (small fixed images). A list given replaces its default. <Image> snaps to these widths, and the server serves exactly them, so an image never asks for a width the optimizer refuses. The largest is the optimizer's maximum width. Default: 640 to 3840 for deviceSizes, 32 to 384 for imageSizes.
sizes? readonly sizes?: readonly number[] Same as widths.deviceSizes, kept for existing configurations. Not with widths.
formats? readonly formats?: readonly ("original" | "webp" | "avif" | "jpeg" | "png")[] The formats the optimizer may produce. original is the source's own. Default: all of them.
qualities? readonly qualities?: readonly number[] The qualities the optimizer may produce (1 to 100). Default: any.