Skip to content

Commit 36b3f43

Browse files
authored
Merge pull request #14 from geulDa/setting/#11/svg-sprite-setting
Setting: svg sprite setting
2 parents e62b4b9 + 884af66 commit 36b3f43

25 files changed

+1472
-7
lines changed

next.config.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
import type { NextConfig } from "next";
1+
import path from 'path';
2+
import type { NextConfig } from 'next';
3+
4+
const ICON_DIR = path.resolve(__dirname, 'src/shared/icons/source');
25

36
const nextConfig: NextConfig = {
4-
/* config options here */
57
reactStrictMode: true,
8+
webpack: (config) => {
9+
const svgRule = config.module.rules.find(
10+
// @ts-ignore
11+
(rule) => rule.test && rule.test.test && rule.test.test('.svg'),
12+
);
13+
if (svgRule) {
14+
// @ts-ignore
15+
svgRule.exclude = [...(svgRule.exclude || []), ICON_DIR];
16+
}
17+
18+
config.module.rules.push({
19+
test: /\.svg$/,
20+
include: [ICON_DIR],
21+
use: [
22+
{
23+
loader: require.resolve('svg-sprite-loader'),
24+
options: {
25+
symbolId: 'icon-[name]',
26+
extract: false,
27+
},
28+
},
29+
],
30+
});
31+
32+
return config;
33+
},
634
};
735

836
export default nextConfig;

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "eslint"
9+
"lint": "eslint",
10+
"icons:clean": "svgo -r -f src/shared/icons/source --config=./svgo.config.mjs --multipass",
11+
"icons:gen": "pnpm dlx tsx src/shared/icons/scripts/generate-icon-list.ts ",
12+
"icons": "pnpm icons:clean && pnpm icons:gen"
1013
},
1114
"dependencies": {
1215
"axios": "^1.12.2",
16+
"clsx": "^2.1.1",
1317
"next": "15.5.4",
1418
"react": "19.1.0",
1519
"react-dom": "19.1.0",
16-
"react-hook-form": "^7.64.0"
20+
"react-hook-form": "^7.64.0",
21+
"svgo": "^4.0.0"
1722
},
1823
"devDependencies": {
1924
"@eslint/eslintrc": "^3",
@@ -23,6 +28,7 @@
2328
"@types/react-dom": "^19",
2429
"eslint": "^9",
2530
"eslint-config-next": "15.5.4",
31+
"svg-sprite-loader": "^6.0.11",
2632
"tailwindcss": "4.1.14",
2733
"typescript": "^5"
2834
}

0 commit comments

Comments
 (0)