Skip to content

Commit 1721586

Browse files
author
zhaoshiwei1
committed
refactor: adjust typedRoutes and image size configurations in next.config.js to optimize build performance in production
1 parent 0508f91 commit 1721586

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

next.config.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* 文档:https://nextjs.org/docs/app/api-reference/next-config-js
1010
*/
1111
const isProd = process.env.NODE_ENV === "production";
12+
1213
const nextConfig = {
1314
// 实验性功能配置
1415
experimental: {
@@ -22,8 +23,10 @@ const nextConfig = {
2223
* - 防止路由拼写错误
2324
* - 提供更好的 IDE 支持
2425
* - 重构时自动更新路由引用
26+
*
27+
* 注意:在生产环境构建时可能消耗较多资源,如果构建卡住可以临时禁用
2528
*/
26-
typedRoutes: true,
29+
typedRoutes: !isProd, // 生产环境禁用以加快构建速度
2730
},
2831
basePath: "",
2932
// 图片优化配置
@@ -42,10 +45,10 @@ const nextConfig = {
4245
],
4346
// 图片格式优化
4447
formats: ["image/webp", "image/avif"],
45-
// 设备尺寸
46-
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
47-
// 图片尺寸
48-
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
48+
// 设备尺寸(减少尺寸数量以加快构建)
49+
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
50+
// 图片尺寸(减少尺寸数量以加快构建)
51+
imageSizes: [16, 32, 48, 64, 96, 128, 256],
4952
// 最小缓存时间(秒)
5053
minimumCacheTTL: 60,
5154
},

0 commit comments

Comments
 (0)