diff --git a/.changeset/curvy-flies-carry.md b/.changeset/curvy-flies-carry.md new file mode 100644 index 000000000000..bd27d04b270d --- /dev/null +++ b/.changeset/curvy-flies-carry.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/enhanced-img': minor +--- + +feat: add support for targeting `enhanced\:img` in CSS diff --git a/documentation/docs/40-best-practices/07-images.md b/documentation/docs/40-best-practices/07-images.md index b86513216ffa..972cc16af48d 100644 --- a/documentation/docs/40-best-practices/07-images.md +++ b/documentation/docs/40-best-practices/07-images.md @@ -27,8 +27,6 @@ Doing this manually is tedious. There are a variety of techniques you can use, d `@sveltejs/enhanced-img` is a plugin offered on top of Vite's built-in asset handling. It provides plug and play image processing that serves smaller file formats like `avif` or `webp`, automatically sets the intrinsic `width` and `height` of the image to avoid layout shift, creates images of multiple sizes for various devices, and strips EXIF data for privacy. It will work in any Vite-based project including, but not limited to, SvelteKit projects. > [!NOTE] As a build plugin, `@sveltejs/enhanced-img` can only optimize files located on your machine during the build process. If you have an image located elsewhere (such as a path served from your database, CMS, or backend), please read about [loading images dynamically from a CDN](#Loading-images-dynamically-from-a-CDN). -> -> **WARNING**: The `@sveltejs/enhanced-img` package is experimental. It uses pre-1.0 versioning and may introduce breaking changes with every minor version release. ### Setup @@ -67,7 +65,7 @@ At build time, your `` tag will be replaced with an `` wrappe You should provide your image at 2x resolution for HiDPI displays (a.k.a. retina displays). `` will automatically take care of serving smaller versions to smaller devices. -If you wish to add styles to your ``, you should add a `class` and target that. +> [!NOTE] if you wish to use a [tag name CSS selector](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Basic_selectors#type_selectors) in your ` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fb5fae117180..d66201aa260d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -315,6 +315,9 @@ importers: specifier: ^1.1.2 version: 1.1.2 devDependencies: + '@sveltejs/vite-plugin-svelte': + specifier: ^5.0.1 + version: 5.0.1(svelte@5.23.1)(vite@6.0.11(@types/node@18.19.50)(lightningcss@1.24.1)) '@types/estree': specifier: ^1.0.5 version: 1.0.6