Skip to content

Commit

Permalink
Add support for WebP and AVIF image formats (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
adenj authored Dec 4, 2024
1 parent 6dab604 commit 187a862
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/eighty-masks-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'sku': minor
---
Add WebP and AVIF image format support to sku

Support for `webp` and `avif` image formats has been added. Note that browser support for these formats may vary. To ensure compatibility across browsers, consumers are advised to use the `<picture>` element with fallback formats.
12 changes: 11 additions & 1 deletion docs/docs/extra-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
## Images

The following images types are supported in sku:
`bmp`, `gif`, `jpeg`, `png` and `svg`.
`bmp`, `gif`, `jpeg`, `png`, `svg`, `webp` and `avif`.

?> Browser support for `webp` and `avif` varies. To ensure compatability across browsers, consider providing fallback image formats using the [`picture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) element.

```html
<picture>
<source srcset="image.avif" type="image/avif" />
<source srcset="image.webp" type="image/webp" />
<img src="image.png" />
</picture>
```

If you want to use a currently unsupported format feel free to submit a PR or contact #sku-support.

Expand Down
2 changes: 1 addition & 1 deletion packages/sku/config/webpack/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ module.exports = {
resolvePackage,
TYPESCRIPT: new RegExp(`\.(${extensions.ts.join('|')})$`),
JAVASCRIPT: new RegExp(`\.(${extensions.js.join('|')})$`),
IMAGE: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
IMAGE: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.webp$/, /\.avif$/],
SVG: /\.svg$/,
};

0 comments on commit 187a862

Please sign in to comment.