Skip to content

Commit

Permalink
Add AVIF image support (#9611)
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>
  • Loading branch information
hongbo-miao and ianschmitz committed Oct 14, 2020
1 parent d5c0fe2 commit 6a51dcd
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
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
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 6a51dcd

Please sign in to comment.