(config)
| 1 | /** @type {import('next').NextConfig} */ |
| 2 | const nextConfig = { |
| 3 | webpack(config) { |
| 4 | // Grab the existing rule that handles SVG imports |
| 5 | const fileLoaderRule = config.module.rules.find((rule) => |
| 6 | rule.test?.test?.(".svg") |
| 7 | ); |
| 8 | |
| 9 | config.module.rules.push( |
| 10 | // Reapply the existing rule, but only for svg imports ending in ?url |
| 11 | { |
| 12 | ...fileLoaderRule, |
| 13 | test: /\.svg$/i, |
| 14 | resourceQuery: /url/, // *.svg?url |
| 15 | }, |
| 16 | // Convert all other *.svg imports to React components |
| 17 | { |
| 18 | test: /\.svg$/i, |
| 19 | issuer: fileLoaderRule.issuer, |
| 20 | resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url |
| 21 | use: ["@svgr/webpack"], |
| 22 | } |
| 23 | ); |
| 24 | |
| 25 | // Modify the file loader rule to ignore *.svg, since we have it handled now. |
| 26 | fileLoaderRule.exclude = /\.svg$/i; |
| 27 | |
| 28 | return config; |
| 29 | }, |
| 30 | }; |
| 31 | |
| 32 | export default nextConfig; |
nothing calls this directly
no outgoing calls
no test coverage detected