Klenodexempel

Plugin Reference

Asset Plugins

SvgPlugin and ImagePlugin turn imported media into content-hashed browser assets with runtime-safe metadata.

SvgPlugin

SvgPlugin emits SVG assets and returns metadata with src, width, height, and content_type. Width and height come from the SVG element when available, or from the viewBox when they can be inferred.

Logo = import("./logo.svg")

ImagePlugin

ImagePlugin emits raster source assets, generated default images, and generated variants. Imports can request widths, output formats, sizes, and quality.

Photo = import("./photo.jpg?width=320,640&format=webp&quality=82")

Runtime metadata includes src, dimensions, variants, srcset, and sizes. Generated image work is queued as CPU-bound asset generation.

Cache Behavior

Generated assets are content-hashed and can be written as they complete during build output. Existing generated files can be skipped when their output path is already present.