Skip to content

Commit

Permalink
fix(webpack): svgr import 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
son-daehyeon committed Sep 19, 2024
1 parent ad04be1 commit 4a11f3f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions image.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.svg?url' {
const content: any;
export default content;
}
21 changes: 17 additions & 4 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ const nextConfig = {
],
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'));

config.module.rules.push(
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/,
},
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] },
use: ['@svgr/webpack'],
},
);

fileLoaderRule.exclude = /\.svg$/i;

return config;
},
Expand Down
2 changes: 1 addition & 1 deletion src/component/activity/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useForm } from '@/hook';

import { WinkApi } from '@/api';

import avatarImage from '@/public/profile.svg';
import avatarImage from '@/public/profile.svg?url';

import * as yup from 'yup';

Expand Down
8 changes: 4 additions & 4 deletions src/component/page/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React from 'react';
import Image, { StaticImageData } from 'next/image';
import Link from 'next/link';

import Logo from '@/public/footer/logo.svg';
import GithubIcon from '@/public/icon/footer/github.svg';
import InstagramIcon from '@/public/icon/footer/instagram.svg';
import TistoryIcon from '@/public/icon/footer/tistory.svg';
import Logo from '@/public/footer/logo.svg?url';
import GithubIcon from '@/public/icon/footer/github.svg?url';
import InstagramIcon from '@/public/icon/footer/instagram.svg?url';
import TistoryIcon from '@/public/icon/footer/tistory.svg?url';

interface Link {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/component/page/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { WinkApi } from '@/api';

import Dropdown from '@/public/icon/arrow-down.svg';
import logo from '@/public/logo.png';
import avatar from '@/public/profile.svg';
import avatar from '@/public/profile.svg?url';

import { AnimatePresence, motion } from 'framer-motion';

Expand Down

0 comments on commit 4a11f3f

Please sign in to comment.