-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnext.config.ts
More file actions
93 lines (91 loc) · 1.98 KB
/
next.config.ts
File metadata and controls
93 lines (91 loc) · 1.98 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
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
/* config options here */
experimental: {},
typescript: {
ignoreBuildErrors: true // 忽略 TypeScript 检查
},
turbopack: {
root: process.cwd()
},
// 优化Webpack构建
webpack: (config: any, { dev }: { dev: boolean; isServer: boolean }) => {
// 生产环境优化
if (!dev) {
config.optimization = {
...config.optimization,
// 限制并发构建任务
minimize: true,
// 启用代码分割优化
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
}
}
}
}
// 限制CPU使用
config.parallelism = 2
}
return config
},
reactStrictMode: true,
transpilePackages: [
'@ant-design',
'antd',
'rc-util',
'rc-pagination',
'rc-picker',
'rc-tree',
'rc-table',
'rc-input'
],
i18n: {
locales: ['zh-CN', 'zh-TW', 'en'],
defaultLocale: 'zh-CN',
localeDetection: false
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com'
},
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com'
}
],
formats: ['image/webp', 'image/avif'],
minimumCacheTTL: 60,
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384]
},
async headers() {
return [
{
source: '/_next/image(.*)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
},
{
source: '/img/(.*)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=3600, must-revalidate'
}
]
}
]
}
}
export default nextConfig