diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 5e1935d8a0e..c88bdb9809e 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -384,6 +384,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. diff --git a/packages/react-scripts/lib/react-app.d.ts b/packages/react-scripts/lib/react-app.d.ts index 981cd73472c..624c875ec80 100644 --- a/packages/react-scripts/lib/react-app.d.ts +++ b/packages/react-scripts/lib/react-app.d.ts @@ -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;