-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathnext.config.mjs
More file actions
101 lines (98 loc) · 2.83 KB
/
next.config.mjs
File metadata and controls
101 lines (98 loc) · 2.83 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
// next.config.mjs
import { createMDX } from "fumadocs-mdx/next";
import createNextIntlPlugin from "next-intl/plugin";
/**
* IMPORTANT: remarkImage 配置已移至 source.config.ts 统一管理
*
* 原因:
* 1. 避免配置冲突 - 之前这里的 remarkPlugins 会覆盖 source.config.ts 的配置
* 2. 统一管理 - 所有 MDX 相关配置(remarkPlugins, rehypePlugins, remarkImageOptions)
* 都在 source.config.ts 中,便于维护
*
* 如需修改图片处理配置,请前往 source.config.ts
*/
const withMDX = createMDX({
configPath: "source.config.ts",
// mdxOptions 留空,让 source.config.ts 统一管理所有 remark/rehype 插件
});
const withNextIntl = createNextIntlPlugin("./i18n.ts");
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "*.githubusercontent.com",
pathname: "/**",
},
{
protocol: "https",
hostname: "*.github.io",
pathname: "/**",
},
{
protocol: "https",
hostname: "*.r2.dev",
pathname: "/**",
},
{
protocol: "https",
hostname: "cdn.nlark.com",
pathname: "/**",
},
{
protocol: "https",
hostname: "*.amazonaws.com",
pathname: "/**",
},
{
protocol: "https",
hostname: "*.coly.cc",
pathname: "/**",
},
{
protocol: "https",
hostname: "cdn.discordapp.com",
pathname: "/**",
},
{
protocol: "https",
hostname: "media.discordapp.net",
pathname: "/**",
},
{
protocol: "https",
hostname: "placehold.co",
pathname: "/**",
},
{
protocol: "https",
hostname: "mirrors.creativecommons.org",
pathname: "/**",
},
],
/**
* CRITICAL: 禁用 Next.js 图片优化
*
* 原因:Vercel 的图片优化配额已耗尽
*
* 重要说明:
* - Vercel 免费计划的图片优化有配额限制(每月 1000 次源图片优化)
* - 我们的网站图片较多,很快会超出配额
* - 超出配额后会导致图片加载失败或构建失败
* - 因此必须设置 unoptimized: true 禁用图片优化
*
* 影响:
* - ✅ 图片会以原始格式和尺寸提供(不会被 Vercel 优化)
* - ✅ 不消耗 Vercel 配额
* - ⚠️ 失去自动格式转换(WebP/AVIF)和尺寸优化
* - ⚠️ 可能有轻微的性能影响(但我们已使用 Cloudflare R2 等 CDN)
*
* 如果未来升级到付费计划或迁移到自托管,可以考虑移除此选项
*/
unoptimized: true,
formats: ["image/avif", "image/webp"],
},
};
export default withNextIntl(withMDX(config));