@itznotabug/emage-svelte
v0.2.2
Published
Build-time image optimization and dynamic local image catalogs for Svelte
Maintainers
Readme
@itznotabug/emage-svelte
Build-time image optimization for Svelte + Vite, including opt-in finite catalogs for image paths selected at runtime.
This package replaces @itznotabug/enhanced-img and is an extended successor to
@sveltejs/[email protected],
with the familiar enhancedImages(), <enhanced:img>, and ?enhanced API.
Install
bun add --dev @itznotabug/emage-sveltePlace the plugin before Svelte:
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { enhancedImages } from '@itznotabug/emage-svelte';
export default {
plugins: [enhancedImages(), svelte()]
};<enhanced:img src="./hero.jpg" alt="Product screenshot" />For runtime-selected local paths, declare a finite catalog:
enhancedImages({
dynamic: 'src/assets/**/*.{avif,gif,jpeg,jpg,png,tiff,webp}'
});{#each products as product}
<enhanced:img src={product.image} alt={product.name} />
{/each}Files must exist at build time. Remote URLs, SVGs, and unmatched paths pass through as
plain <img> elements.
