From 6731a636f480d5af0b95f6f206eb061abcbf3adf Mon Sep 17 00:00:00 2001 From: Niraj Nillawar <149431848+NirajDN@users.noreply.github.com> Date: Sun, 20 Jul 2025 03:42:12 +0530 Subject: [PATCH] Update next.config.js(1) --- next.config.js | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/next.config.js b/next.config.js index 7a67a9177b2a..7007277da55e 100644 --- a/next.config.js +++ b/next.config.js @@ -1,32 +1,40 @@ import fs from 'fs' import path from 'path' - import frontmatter from 'gray-matter' -// Replace imports with hardcoded values -const ROOT = process.env.ROOT || '.' + +// 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 that step of build. - // type-checking still occurs in the Dockerfile build + // 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', @@ -35,40 +43,33 @@ export default { 'mixed-decls', ], }, + async rewrites() { - const DEFAULT_VERSION = 'free-pro-team@latest' - return productIds.map((productId) => { - return { - source: `/${productId}/:path*`, - destination: `/${DEFAULT_VERSION}/${productId}/:path*`, - } - }) + return productIds.map((productId) => ({ + source: `/${productId}/:path*`, + destination: `/${DEFAULT_VERSION}/${productId}/:path*`, + })) }, - webpack: (config) => { + + 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 }, - // https://nextjs.org/docs/api-reference/next.config.js/compression + // Disable compression (optional, depends on your infrastructure) compress: false, - // ETags break stale content serving from the CDN. When a response has - // an ETag, the CDN attempts to revalidate the content in the background. - // This causes problems with serving stale content, since upon revalidating - // the CDN marks the cached content as "fresh". + // Disable ETags to avoid stale content issues with CDN generateEtags: false, experimental: { - // The output of our getServerSideProps() return large chunks of - // data because it contains our rendered Markdown. - // The default, for a "Large Page Data" warning is 128KB - // but many of our pages are much larger. - // The warning is: https://nextjs.org/docs/messages/large-page-data - largePageDataBytes: 1024 * 1024, // 1 MB + // Increase large page data warning threshold to 1MB + largePageDataBytes: 1024 * 1024, - // This makes it so that going Back will scroll to the previous position + // Enable scroll restoration when navigating back/forward scrollRestoration: true, },