-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.mjs
More file actions
138 lines (133 loc) · 3.14 KB
/
next.config.mjs
File metadata and controls
138 lines (133 loc) · 3.14 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { createMDX } from 'fumadocs-mdx/next'
const withMDX = createMDX()
// Only import and use bundle analyzer when needed to avoid production dependency issues
let withBundleAnalyzer = (config) => config
if (process.env.ANALYZE === 'true') {
try {
// Use dynamic import with require for compatibility
const bundleAnalyzer = require('@next/bundle-analyzer')
withBundleAnalyzer = bundleAnalyzer({
enabled: true,
})
} catch (error) {
console.warn(
'Bundle analyzer not available, skipping analysis:',
error.message,
)
withBundleAnalyzer = (config) => config
}
}
const securityHeaders = [
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'DENY',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block', // optional, deprecated
},
]
/** @type {import('next').NextConfig} */
const config = {
// Removed 'output: standalone' to enable static generation for docs pages
// while maintaining server-side functionality for other pages
reactStrictMode: true,
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
// Enable SWC minification
swcMinify: true,
// Compiler optimizations
compiler: {
removeConsole:
process.env.NODE_ENV === 'production'
? {
exclude: ['error', 'warn'],
}
: false,
},
// Enable static generation optimization
experimental: {
optimizePackageImports: [
'fumadocs-ui',
'fumadocs-core',
'lucide-react',
'motion',
'@radix-ui/react-dialog',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-slot',
],
},
async headers () {
return [
{
source: '/(.*)',
headers: securityHeaders,
},
]
},
async redirects () {
return [
{
source: '/',
destination: '/docs',
permanent: false,
},
{
source: '/devbox',
destination: '/products/devbox',
permanent: true,
},
{
source: '/education',
destination: '/solutions/industries/education',
permanent: true,
},
]
},
images: {
// Only disable image optimization during Docker builds
unoptimized: process.env.DOCKER_BUILD === 'true',
remotePatterns: [
{
protocol: 'https',
hostname: 'oss.laf.run',
port: '',
pathname: '/**',
search: '',
},
{
protocol: 'https',
hostname: 'images.tryfastgpt.ai',
port: '',
pathname: '/**',
search: '',
},
{
protocol: 'https',
hostname: 'cdn.jsdelivr.net',
port: '',
pathname: '/**',
search: '',
},
{
protocol: 'https',
hostname: 'images.sealos.run',
port: '',
pathname: '/**',
search: '',
},
],
formats: ['image/webp', 'image/avif'],
minimumCacheTTL: 60,
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
}
export default withBundleAnalyzer(withMDX(config))