Skip to content

Commit 8d103e3

Browse files
committed
feat: update config
1 parent 4fc432d commit 8d103e3

File tree

2 files changed

+48
-31
lines changed

2 files changed

+48
-31
lines changed

next.config.ts

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
1-
import type { NextConfig } from 'next';
1+
import type { NextConfig } from 'next'
22

33
const nextConfig: NextConfig = {
44
/* config options here */
55
experimental: {},
66
typescript: {
7-
ignoreBuildErrors: true, // 忽略 TypeScript 检查
7+
ignoreBuildErrors: true // 忽略 TypeScript 检查
88
},
9-
eslint: {
10-
ignoreDuringBuilds: true, // 忽略 ESLint 检查
9+
turbopack: {
10+
root: process.cwd()
1111
},
12-
turbopack: {},
13-
webpack: (config: any) => {
14-
// 禁用缓存序列化警告
15-
config.infrastructureLogging = {
16-
level: 'error',
17-
};
18-
return config;
12+
// 优化Webpack构建
13+
webpack: (config: any, { dev }: { dev: boolean; isServer: boolean }) => {
14+
// 生产环境优化
15+
if (!dev) {
16+
config.optimization = {
17+
...config.optimization,
18+
// 限制并发构建任务
19+
minimize: true,
20+
// 启用代码分割优化
21+
splitChunks: {
22+
chunks: 'all',
23+
cacheGroups: {
24+
vendor: {
25+
test: /[\\/]node_modules[\\/]/,
26+
name: 'vendors',
27+
chunks: 'all'
28+
}
29+
}
30+
}
31+
}
32+
// 限制CPU使用
33+
config.parallelism = 2
34+
}
35+
return config
1936
},
2037
reactStrictMode: true,
2138
transpilePackages: [
@@ -26,28 +43,28 @@ const nextConfig: NextConfig = {
2643
'rc-picker',
2744
'rc-tree',
2845
'rc-table',
29-
'rc-input',
46+
'rc-input'
3047
],
3148
i18n: {
3249
locales: ['zh-CN', 'zh-TW', 'en'],
3350
defaultLocale: 'zh-CN',
34-
localeDetection: false,
51+
localeDetection: false
3552
},
3653
images: {
3754
remotePatterns: [
3855
{
3956
protocol: 'https',
40-
hostname: 'res.cloudinary.com',
57+
hostname: 'res.cloudinary.com'
4158
},
4259
{
4360
protocol: 'https',
44-
hostname: 'avatars.githubusercontent.com',
45-
},
61+
hostname: 'avatars.githubusercontent.com'
62+
}
4663
],
4764
formats: ['image/webp', 'image/avif'],
4865
minimumCacheTTL: 60,
4966
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
50-
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
67+
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384]
5168
},
5269
async headers() {
5370
return [
@@ -56,21 +73,21 @@ const nextConfig: NextConfig = {
5673
headers: [
5774
{
5875
key: 'Cache-Control',
59-
value: 'public, max-age=31536000, immutable',
60-
},
61-
],
76+
value: 'public, max-age=31536000, immutable'
77+
}
78+
]
6279
},
6380
{
6481
source: '/img/(.*)',
6582
headers: [
6683
{
67-
key: 'Cache-Control',
68-
value: 'public, max-age=86400',
69-
},
70-
],
71-
},
72-
];
73-
},
74-
};
84+
key: 'Cache-Control',
85+
value: 'public, max-age=86400'
86+
}
87+
]
88+
}
89+
]
90+
}
91+
}
7592

76-
export default nextConfig;
93+
export default nextConfig

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kaiyuanshe",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
@@ -13,7 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@giscus/react": "^3.1.0",
16-
"@next/third-parties": "^15.3.3",
16+
"@next/third-parties": "^16.0.7",
1717
"@types/leaflet": "^1.9.20",
1818
"antd": "^5.25.4",
1919
"cloudinary": "^2.6.1",

0 commit comments

Comments
 (0)