Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WebP and AVIF image formats #1119

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Added support for `webp` and `avif` image formats in, and updated documentation to include these formats in the list of supported image types.
adenj marked this conversation as resolved.
Show resolved Hide resolved
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.
adenj marked this conversation as resolved.
Show resolved Hide resolved

```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$/,
};
Loading