Skip to content

Commit 6a51dcd

Browse files
Add AVIF image support (#9611)
Co-authored-by: Ian Schmitz <[email protected]>
1 parent d5c0fe2 commit 6a51dcd

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/react-scripts/config/webpack.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,17 @@ module.exports = function (webpackEnv) {
379379
// match the requirements. When no loader matches it will fall
380380
// back to the "file" loader at the end of the loader list.
381381
oneOf: [
382+
// TODO: Merge this config once `image/avif` is in the mime-db
383+
// https://github.com/jshttp/mime-db
384+
{
385+
test: [/\.avif$/],
386+
loader: require.resolve('url-loader'),
387+
options: {
388+
limit: imageInlineSizeLimit,
389+
mimetype: 'image/avif',
390+
name: 'static/media/[name].[hash:8].[ext]',
391+
},
392+
},
382393
// "url" loader works like "file" loader except that it embeds assets
383394
// smaller than specified limit in bytes as data URLs to avoid requests.
384395
// A missing `test` is equivalent to a match.

packages/react-scripts/lib/react-app.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ declare namespace NodeJS {
99
}
1010
}
1111

12+
declare module '*.avif' {
13+
const src: string;
14+
export default src;
15+
}
16+
1217
declare module '*.bmp' {
1318
const src: string;
1419
export default src;

0 commit comments

Comments
 (0)