11'use strict' ;
22import createNextIntlPlugin from 'next-intl/plugin' ;
33
4- import { OPEN_NEXT_CLOUDFLARE } from './next.constants.cloudflare.mjs' ;
54import { BASE_PATH , ENABLE_STATIC_EXPORT } from './next.constants.mjs' ;
6- import { getImagesConfig } from './next.image.config.mjs' ;
75import { redirects , rewrites } from './next.rewrites.mjs' ;
86
9- const getDeploymentId = async ( ) => {
10- if ( OPEN_NEXT_CLOUDFLARE ) {
11- // If we're building for the Cloudflare deployment we want to set
12- // an appropriate deploymentId (needed for skew protection)
13- const openNextAdapter = await import ( '@opennextjs/cloudflare' ) ;
7+ /**
8+ * The deployment platform this build targets. All platform-specific behavior
9+ * lives in the `platforms/*` workspace packages; see `platforms/README.md`.
10+ *
11+ * Vercel deployments are detected automatically; the Cloudflare build scripts
12+ * set the variable themselves.
13+ */
14+ const DEPLOYMENT_PLATFORM =
15+ process . env . NEXT_PUBLIC_DEPLOYMENT_PLATFORM ||
16+ ( process . env . VERCEL ? 'vercel' : 'default' ) ;
1417
15- return openNextAdapter . getDeploymentId ( ) ;
16- }
17-
18- return undefined ;
19- } ;
18+ const { default : platformConfig } = await import (
19+ `@node-core/platform-${ DEPLOYMENT_PLATFORM } /next.config.mjs`
20+ ) ;
2021
2122/** @type {import('next').NextConfig } */
2223const nextConfig = {
@@ -27,8 +28,19 @@ const nextConfig = {
2728 // We allow the BASE_PATH to be overridden in case that the Website
2829 // is being built on a subdirectory (e.g. /nodejs-website)
2930 basePath : BASE_PATH ,
30- // Vercel/Next.js Image Optimization Settings
31- images : getImagesConfig ( ) ,
31+ images : {
32+ // We disable image optimisation during static export builds
33+ unoptimized : ENABLE_STATIC_EXPORT ,
34+ // We add it to the remote pattern for the static images we use from multiple sources
35+ // to be marked as safe sources (these come from Markdown files)
36+ remotePatterns : [
37+ 'https://avatars.githubusercontent.com/**' ,
38+ 'https://bestpractices.coreinfrastructure.org/**' ,
39+ 'https://raw.githubusercontent.com/nodejs/**' ,
40+ 'https://user-images.githubusercontent.com/**' ,
41+ 'https://website-assets.oramasearch.com/**' ,
42+ ] . map ( url => new URL ( url ) ) ,
43+ } ,
3244 serverExternalPackages : [ 'twoslash' ] ,
3345 outputFileTracingIncludes : {
3446 // Twoslash needs TypeScript declarations to function, and, by default, Next.js
@@ -81,8 +93,18 @@ const nextConfig = {
8193 // Faster Development Servers with Turbopack
8294 turbopackFileSystemCacheForDev : true ,
8395 } ,
84- deploymentId : await getDeploymentId ( ) ,
8596} ;
8697
8798const withNextIntl = createNextIntlPlugin ( './i18n.tsx' ) ;
88- export default withNextIntl ( nextConfig ) ;
99+
100+ export default withNextIntl ( {
101+ ...nextConfig ,
102+ ...platformConfig ,
103+ env : {
104+ // Inlined into the bundles at build time so runtime code (e.g.
105+ // `#site/platform/analytics`) can branch on the platform, letting
106+ // bundlers drop the branches (and packages) of the other platforms.
107+ NEXT_PUBLIC_DEPLOYMENT_PLATFORM : DEPLOYMENT_PLATFORM ,
108+ ...platformConfig . env ,
109+ } ,
110+ } ) ;
0 commit comments