- Updated @primer/react to version 37.30.0 and added @primer/primitives and @primer/view-components. - Introduced a new global CSS file for consolidated Primer React styles. - Added empty stubs for deprecated and removed components in the view-components library. - Updated the _app.tsx file to include the new global CSS. - Changed the import of Banner component from @primer/react/drafts to @primer/react/experimental in SearchOverlay.
96 lines
3.2 KiB
JavaScript
96 lines
3.2 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
import frontmatter from 'gray-matter'
|
|
import { getLogLevelNumber } from '#src/observability/logger/lib/log-levels.js'
|
|
|
|
// Replace imports with hardcoded values
|
|
const ROOT = process.env.ROOT || '.'
|
|
|
|
// Hard-coded language keys to avoid TypeScript import in config file
|
|
const languageKeys = ['en', 'es', 'ja', 'pt', 'zh', 'ru', 'fr', 'ko', 'de']
|
|
|
|
const homepage = path.posix.join(ROOT, 'content/index.md')
|
|
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
|
|
const productIds = data.children
|
|
|
|
export default {
|
|
// speed up production `next build` by ignoring typechecking during that step of build.
|
|
// type-checking still occurs in the Dockerfile build
|
|
typescript: {
|
|
ignoreBuildErrors: true,
|
|
},
|
|
eslint: {
|
|
ignoreDuringBuilds: true,
|
|
},
|
|
i18n: {
|
|
locales: languageKeys,
|
|
defaultLocale: 'en',
|
|
},
|
|
sassOptions: {
|
|
quietDeps: true,
|
|
silenceDeprecations: [
|
|
'legacy-js-api',
|
|
'import',
|
|
'global-builtin',
|
|
'color-4-api',
|
|
'mixed-decls',
|
|
],
|
|
// Allow resolving our local stubs for removed @primer/view-components sass partials
|
|
includePaths: [path.join(process.cwd(), 'src/frame/stylesheets/vendor')],
|
|
},
|
|
// Don't use automatic Next.js logging in dev unless the log level is `debug` or higher
|
|
// See `src/observability/logger/README.md` for log levels
|
|
logging: getLogLevelNumber() < 3 ? false : {},
|
|
async rewrites() {
|
|
const DEFAULT_VERSION = 'free-pro-team@latest'
|
|
return productIds.map((productId) => {
|
|
return {
|
|
source: `/${productId}/:path*`,
|
|
destination: `/${DEFAULT_VERSION}/${productId}/:path*`,
|
|
}
|
|
})
|
|
},
|
|
webpack: (config) => {
|
|
config.experiments = config.experiments || {}
|
|
config.experiments.topLevelAwait = true
|
|
config.resolve.fallback = { fs: false, async_hooks: false }
|
|
// Alias missing Ruby view-components SCSS imports to local empty stubs
|
|
config.resolve.alias = {
|
|
...(config.resolve.alias || {}),
|
|
'@primer/view-components': path.join(
|
|
process.cwd(),
|
|
'src/frame/stylesheets/vendor/@primer/view-components',
|
|
),
|
|
// Force ESM build of @primer/react so restored TabNav export is used and to avoid CJS CSS requires
|
|
'@primer/react$': path.join(process.cwd(), 'node_modules/@primer/react/lib-esm/index.js'),
|
|
}
|
|
return config
|
|
},
|
|
|
|
// https://nextjs.org/docs/api-reference/next.config.js/compression
|
|
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".
|
|
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
|
|
|
|
// This makes it so that going Back will scroll to the previous position
|
|
scrollRestoration: true,
|
|
},
|
|
|
|
compiler: {
|
|
styledComponents: true,
|
|
},
|
|
}
|