Skip to content

Commit

Permalink
try try
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Jan 25, 2025
1 parent 412aa2a commit 24f4fae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
26 changes: 4 additions & 22 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,10 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
reactStrictMode: true,
webpack(config) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg'),
);

config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},
// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: {not: [...fileLoaderRule.resourceQuery.not, /url/]}, // exclude if *.svg?url
use: ['@svgr/webpack'],
}
);
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;
config.module.rules.push({
test: /\.svg$/i,
use: ['@svgr/webpack'],
});

return config;
}
Expand Down
5 changes: 0 additions & 5 deletions src/types/custom.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions svgr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ declare module '*.svg' {
const content: FC<SVGProps<SVGElement>>;
export default content;
}

declare module '*.svg?url' {
const content: any;
export default content;
}

0 comments on commit 24f4fae

Please sign in to comment.