Configuration

Swift Rust is configured via swift-rust.config.json at the project root.

Schema

swift-rust.config.json
{
  "rendering": "ssr-wasm",
  "image": {
    "domains": ["cdn.example.com"],
    "formats": ["image/avif", "image/webp"],
    "deviceSizes": [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
    "imageSizes": [16, 32, 48, 64, 96, 128, 256, 384],
    "minimumCacheTTL": 60
  },
  "font": {
    "subsets": ["latin"],
    "display": "swap",
    "preload": true,
    "adjustFontFallback": true,
    "fallback": ["system-ui", "sans-serif"]
  },
  "pdf": {
    "defaultPageSize": "A4",
    "defaultOrientation": "portrait",
    "compress": true
  }
}

TypeScript

For type-safe config, use defineConfig:

swift-rust.config.ts
import { defineConfig } from "swift-rust";

export default defineConfig({
  rendering: "ssr-wasm",
  image: { domains: ["cdn.example.com"] },
  font: { subsets: ["latin"], display: "swap" },
});