Skip to content

Commit

Permalink
Add AVIF image support (facebook#9611)
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Schmitz <[email protected]>
  • Loading branch information
2 people authored and abhiisheek committed May 24, 2023
1 parent 14310fc commit 2f276e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ module.exports = function (webpackEnv) {
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [
// TODO: Merge this config once `image/avif` is in the mime-db
// https://github.com/jshttp/mime-db
{
test: [/\.avif$/],
loader: require.resolve('url-loader'),
options: {
limit: imageInlineSizeLimit,
mimetype: 'image/avif',
name: 'static/media/[name].[hash:8].[ext]',
},
},
// "url" loader works like "file" loader except that it embeds assets
// smaller than specified limit in bytes as data URLs to avoid requests.
// A missing `test` is equivalent to a match.
Expand Down
5 changes: 5 additions & 0 deletions packages/react-scripts/lib/react-app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ declare namespace NodeJS {
}
}

declare module '*.avif' {
const src: string;
export default src;
}

declare module '*.bmp' {
const src: string;
export default src;
Expand Down

0 comments on commit 2f276e3

Please sign in to comment.