Skip to content

Commit 6731a63

Browse files
authored
Update next.config.js(1)
1 parent b63a1fc commit 6731a63

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

next.config.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
import fs from 'fs'
22
import path from 'path'
3-
43
import frontmatter from 'gray-matter'
5-
// Replace imports with hardcoded values
6-
const ROOT = process.env.ROOT || '.'
4+
5+
// Resolve root directory explicitly to avoid ambiguity
6+
const ROOT = process.env.ROOT ?? path.resolve(process.cwd())
77

88
// Hard-coded language keys to avoid TypeScript import in config file
99
const languageKeys = ['en', 'es', 'ja', 'pt', 'zh', 'ru', 'fr', 'ko', 'de']
1010

11+
// Read homepage frontmatter to get product IDs
1112
const homepage = path.posix.join(ROOT, 'content/index.md')
1213
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
1314
const productIds = data.children
1415

16+
const DEFAULT_VERSION = 'free-pro-team@latest'
17+
1518
export default {
16-
// speed up production `next build` by ignoring typechecking during that step of build.
17-
// type-checking still occurs in the Dockerfile build
19+
// Speed up production `next build` by ignoring typechecking during build
20+
// Type-checking still occurs in Dockerfile build step
1821
typescript: {
1922
ignoreBuildErrors: true,
2023
},
24+
25+
// Prevent ESLint errors from breaking builds
2126
eslint: {
2227
ignoreDuringBuilds: true,
2328
},
29+
2430
i18n: {
2531
locales: languageKeys,
2632
defaultLocale: 'en',
2733
},
34+
2835
sassOptions: {
2936
quietDeps: true,
37+
// Silence specific deprecation warnings from sass compiler
3038
silenceDeprecations: [
3139
'legacy-js-api',
3240
'import',
@@ -35,40 +43,33 @@ export default {
3543
'mixed-decls',
3644
],
3745
},
46+
3847
async rewrites() {
39-
const DEFAULT_VERSION = 'free-pro-team@latest'
40-
return productIds.map((productId) => {
41-
return {
42-
source: `/${productId}/:path*`,
43-
destination: `/${DEFAULT_VERSION}/${productId}/:path*`,
44-
}
45-
})
48+
return productIds.map((productId) => ({
49+
source: `/${productId}/:path*`,
50+
destination: `/${DEFAULT_VERSION}/${productId}/:path*`,
51+
}))
4652
},
47-
webpack: (config) => {
53+
54+
webpack(config) {
4855
config.experiments = config.experiments || {}
4956
config.experiments.topLevelAwait = true
57+
// Prevent bundling node 'fs' module on client-side
5058
config.resolve.fallback = { fs: false }
5159
return config
5260
},
5361

54-
// https://nextjs.org/docs/api-reference/next.config.js/compression
62+
// Disable compression (optional, depends on your infrastructure)
5563
compress: false,
5664

57-
// ETags break stale content serving from the CDN. When a response has
58-
// an ETag, the CDN attempts to revalidate the content in the background.
59-
// This causes problems with serving stale content, since upon revalidating
60-
// the CDN marks the cached content as "fresh".
65+
// Disable ETags to avoid stale content issues with CDN
6166
generateEtags: false,
6267

6368
experimental: {
64-
// The output of our getServerSideProps() return large chunks of
65-
// data because it contains our rendered Markdown.
66-
// The default, for a "Large Page Data" warning is 128KB
67-
// but many of our pages are much larger.
68-
// The warning is: https://nextjs.org/docs/messages/large-page-data
69-
largePageDataBytes: 1024 * 1024, // 1 MB
69+
// Increase large page data warning threshold to 1MB
70+
largePageDataBytes: 1024 * 1024,
7071

71-
// This makes it so that going Back will scroll to the previous position
72+
// Enable scroll restoration when navigating back/forward
7273
scrollRestoration: true,
7374
},
7475

0 commit comments

Comments
 (0)