-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnext.config.ts
More file actions
104 lines (92 loc) · 2.61 KB
/
next.config.ts
File metadata and controls
104 lines (92 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import type { Configuration, RuleSetRule } from 'webpack';
/** @type {import('next').NextConfig} */
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const nextConfig = {
reactStrictMode: false,
compiler: {
removeConsole:
process.env.NODE_ENV === 'production' ? { exclude: ['error'] } : false,
},
// 사용하는 패키지만 번들에 포함 (미사용 JS 감소)
experimental: {
optimizePackageImports: ['lodash', 'react-icons', 'lucide-react'],
},
// 정적 에셋 캐시 헤더 (캐시 수명 개선)
async headers() {
return [
{
source: '/:all*(svg|jpg|jpeg|png|gif|ico|webp|woff2)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
];
},
images: {
domains: [
'codin-s3-bucket.s3.ap-northeast-2.amazonaws.com',
'starinu.inu.ac.kr',
'ite.inu.ac.kr',
'ese.inu.ac.kr', // S3 버킷 도메인 추가
'cse.inu.ac.kr',
'inu.ac.kr',
'www.inu.ac.kr'
],
},
output: 'standalone',
webpack: (config: Configuration) => {
// SVGR setting
if (!config.module?.rules) return config;
const fileLoaderRule = config.module.rules.find((rule): rule is RuleSetRule => {
if (typeof rule !== 'object' || rule === null) return false;
const r = rule as RuleSetRule;
const test = r.test;
if (test instanceof RegExp) return test.test('.svg');
if (typeof test === 'function') return test('.svg');
return false;
});
if (!fileLoaderRule) return config;
const baseRule =
typeof fileLoaderRule === 'object' && fileLoaderRule !== null
? { ...fileLoaderRule }
: {};
config.module.rules.push(
{
...baseRule,
test: /\.svg$/i,
resourceQuery: /url/,
},
{
test: /\.svg$/i,
issuer: 'issuer' in fileLoaderRule ? fileLoaderRule.issuer : undefined,
resourceQuery: {
not: [
...(Array.isArray(
(fileLoaderRule.resourceQuery as { not?: unknown[] })?.not
)
? (fileLoaderRule.resourceQuery as { not: RegExp[] }).not
: []),
/url/,
],
},
use: [
{
loader: '@svgr/webpack',
options: {
typescript: true,
ext: 'tsx',
},
},
],
}
);
Object.assign(fileLoaderRule, { exclude: /\.svg$/i });
return config;
},
};
module.exports = withBundleAnalyzer(nextConfig);