-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
107 lines (98 loc) · 2.6 KB
/
next.config.mjs
File metadata and controls
107 lines (98 loc) · 2.6 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
105
106
107
import path from 'path'
import { fileURLToPath } from 'url'
import { dirname } from 'path'
import withPlugins from 'next-compose-plugins'
import withBundleAnalyzer from '@next/bundle-analyzer'
import TerserPlugin from 'terser-webpack-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const sassOptions = {
includePaths: [path.join(__dirname, 'styles')],
}
const nextConfig = {
reactStrictMode: true,
sassOptions,
experimental: {
missingSuspenseWithCSRBailout: false,
},
webpack: (config) => {
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg'),
)
config.module.rules.push(
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
use: ['@svgr/webpack'],
},
)
// config.plugins.push(
// new BundleAnalyzerPlugin({
// generateStatsFile: true,
// analyzerMode: 'static',
// reportFileName: 'bundle-report.html',
// }),
// )
// TerserPlugin 추가
config.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
minify: TerserPlugin.terserMinify,
terserOptions: {
format: {
comments: false, //주석제거
},
compress: {
drop_console: true, //콘솔제거
},
},
}),
new CssMinimizerPlugin(),
],
splitChunks: {
//코드 스플리팅 옵션
chunks: 'all',
minSize: 20000,
minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
},
}
return config
},
}
export default withPlugins(
[
[
withBundleAnalyzer,
{
enabled: process.env.ANALYZE === 'true', // ANALYZE=true일 때만 활성화
},
],
// 다른 플러그인을 여기에 추가할 수 있습니다.
],
nextConfig,
)