-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathnext.config.mjs
64 lines (62 loc) · 1.64 KB
/
next.config.mjs
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
import path from 'path'
import { fileURLToPath } from 'url'
import { withPayload } from '@payloadcms/next/withPayload'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
cssChunking: 'loose',
serverSourceMaps: true,
reactCompiler: false,
staleTimes: {
// dynamic: 30,
static: 180,
},
},
images: {
// dangerouslyAllowSVG: true,
// contentDispositionType: 'attachment',
// contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
port: '',
pathname: '**',
},
],
},
compress: true,
// 重写路径以支持不带语言的路径
async rewrites() {
return [
{
source: '/',
destination: `/en-US`,
},
{
source: '/setting',
destination: '/en-US/setting',
},
{
source: '/setting/:path*',
destination: '/en-US/setting/:path*',
},
{
source: '/chat-room',
destination: '/en-US/chat-room',
},
]
},
webpack: (config) => {
// 设置别名
config.resolve.alias['@'] = path.join(__dirname, 'src')
config.resolve.alias['@@'] = path.join(__dirname, 'public')
config.resolve.alias['&'] = path.join(__dirname, 'src/server')
config.resolve.alias['@payload-config'] = path.join(__dirname, 'src/server/payload/payload.config.ts')
// 重要: 返回修改后的配置
return config
}
}
export default withPayload(nextConfig)