Skip to content

Commit 212f2ba

Browse files
committed
#351 feat(fe): bundlyzer 추가 및 next.js webpack 최적화
1 parent baf9327 commit 212f2ba

File tree

2 files changed

+619
-31
lines changed

2 files changed

+619
-31
lines changed
Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,58 @@
1+
import withBundleAnalyzer from '@next/bundle-analyzer';
2+
import TerserPlugin from 'terser-webpack-plugin';
3+
4+
const mode = process.env.NODE_ENV || 'development';
5+
16
/** @type {import('next').NextConfig} */
27
const nextConfig = {
38
transpilePackages: ['@workspace/ui'],
49
images: {
5-
// eslint-disable-next-line no-undef
610
domains: [process.env.NEXT_PUBLIC_S3_BUCKET_NAME || 'default-domain.com'],
711
},
8-
generateBuildId: async () => {
9-
return 'my-fixed-build-id';
12+
webpack: (config, { isServer }) => {
13+
if (!isServer && mode === 'production') {
14+
// 커스텀 splitChunks 설정
15+
config.optimization.splitChunks = {
16+
chunks: 'all',
17+
minSize: 20000,
18+
maxSize: 0,
19+
minChunks: 1,
20+
maxAsyncRequests: 30,
21+
maxInitialRequests: 30,
22+
automaticNameDelimiter: '~',
23+
cacheGroups: {
24+
reactVendors: {
25+
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
26+
name: 'react-vendors',
27+
chunks: 'all',
28+
priority: 20,
29+
},
30+
vendors: {
31+
test: /[\\/]node_modules[\\/]/,
32+
name: 'vendors',
33+
chunks: 'all',
34+
priority: -10,
35+
},
36+
default: {
37+
minChunks: 2,
38+
priority: -20,
39+
reuseExistingChunk: true,
40+
},
41+
},
42+
};
43+
44+
config.optimization.minimizer = [
45+
new TerserPlugin({
46+
terserOptions: {
47+
compress: {
48+
drop_console: true,
49+
},
50+
},
51+
}),
52+
];
53+
}
54+
return config;
1055
},
1156
};
1257

13-
export default nextConfig;
58+
export default withBundleAnalyzer(nextConfig);

0 commit comments

Comments
 (0)