forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
79 lines (64 loc) · 2.01 KB
/
next.config.js
File metadata and controls
79 lines (64 loc) · 2.01 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
import fs from 'fs'
import path from 'path'
import frontmatter from 'gray-matter'
// Resolve root directory explicitly to avoid ambiguity
const ROOT = process.env.ROOT ?? path.resolve(process.cwd())
// Hard-coded language keys to avoid TypeScript import in config file
const languageKeys = ['en', 'es', 'ja', 'pt', 'zh', 'ru', 'fr', 'ko', 'de']
// Read homepage frontmatter to get product IDs
const homepage = path.posix.join(ROOT, 'content/index.md')
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
const productIds = data.children
const DEFAULT_VERSION = 'free-pro-team@latest'
export default {
// Speed up production `next build` by ignoring typechecking during build
// Type-checking still occurs in Dockerfile build step
typescript: {
ignoreBuildErrors: true,
},
// Prevent ESLint errors from breaking builds
eslint: {
ignoreDuringBuilds: true,
},
i18n: {
locales: languageKeys,
defaultLocale: 'en',
},
sassOptions: {
quietDeps: true,
// Silence specific deprecation warnings from sass compiler
silenceDeprecations: [
'legacy-js-api',
'import',
'global-builtin',
'color-4-api',
'mixed-decls',
],
},
async rewrites() {
return productIds.map((productId) => ({
source: `/${productId}/:path*`,
destination: `/${DEFAULT_VERSION}/${productId}/:path*`,
}))
},
webpack(config) {
config.experiments = config.experiments || {}
config.experiments.topLevelAwait = true
// Prevent bundling node 'fs' module on client-side
config.resolve.fallback = { fs: false }
return config
},
// Disable compression (optional, depends on your infrastructure)
compress: false,
// Disable ETags to avoid stale content issues with CDN
generateEtags: false,
experimental: {
// Increase large page data warning threshold to 1MB
largePageDataBytes: 1024 * 1024,
// Enable scroll restoration when navigating back/forward
scrollRestoration: true,
},
compiler: {
styledComponents: true,
},
}