2021-02-27 07:19:35 +01:00
|
|
|
import os from 'os'
|
2021-06-30 13:44:40 +02:00
|
|
|
import { Header, Redirect, Rewrite } from '../lib/load-custom-routes'
|
2021-07-12 23:38:57 +02:00
|
|
|
import { ImageConfig, imageConfigDefault } from './image-config'
|
2021-02-27 07:19:35 +01:00
|
|
|
|
|
|
|
export type DomainLocales = Array<{
|
|
|
|
http?: true
|
|
|
|
domain: string
|
|
|
|
locales?: string[]
|
|
|
|
defaultLocale: string
|
|
|
|
}>
|
|
|
|
|
2021-07-12 23:38:57 +02:00
|
|
|
type NoOptionals<T> = {
|
|
|
|
[P in keyof T]-?: T[P]
|
|
|
|
}
|
|
|
|
|
|
|
|
export type NextConfigComplete = NoOptionals<NextConfig>
|
|
|
|
|
2021-02-27 07:19:35 +01:00
|
|
|
export type NextConfig = { [key: string]: any } & {
|
|
|
|
i18n?: {
|
|
|
|
locales: string[]
|
|
|
|
defaultLocale: string
|
|
|
|
domains?: DomainLocales
|
|
|
|
localeDetection?: false
|
|
|
|
} | null
|
|
|
|
|
|
|
|
headers?: () => Promise<Header[]>
|
2021-03-26 16:19:48 +01:00
|
|
|
rewrites?: () => Promise<
|
|
|
|
| Rewrite[]
|
|
|
|
| {
|
|
|
|
beforeFiles: Rewrite[]
|
|
|
|
afterFiles: Rewrite[]
|
|
|
|
fallback: Rewrite[]
|
|
|
|
}
|
|
|
|
>
|
2021-02-27 07:19:35 +01:00
|
|
|
redirects?: () => Promise<Redirect[]>
|
2021-07-12 23:38:57 +02:00
|
|
|
|
2021-06-07 22:48:29 +02:00
|
|
|
webpack5?: false
|
2021-06-14 16:20:34 +02:00
|
|
|
excludeDefaultMomentLocales?: boolean
|
2021-02-27 07:19:35 +01:00
|
|
|
|
2021-07-12 23:38:57 +02:00
|
|
|
trailingSlash?: boolean
|
|
|
|
env?: { [key: string]: string }
|
|
|
|
distDir?: string
|
|
|
|
cleanDistDir?: boolean
|
|
|
|
assetPrefix?: string
|
|
|
|
useFileSystemPublicRoutes?: boolean
|
|
|
|
generateBuildId: () => string | null
|
|
|
|
generateEtags?: boolean
|
|
|
|
pageExtensions?: string[]
|
|
|
|
compress?: boolean
|
|
|
|
images?: ImageConfig
|
|
|
|
devIndicators?: {
|
|
|
|
buildActivity?: boolean
|
|
|
|
}
|
|
|
|
onDemandEntries?: {
|
|
|
|
maxInactiveAge?: number
|
|
|
|
pagesBufferLength?: number
|
|
|
|
}
|
|
|
|
amp?: {
|
|
|
|
canonicalBase?: string
|
|
|
|
}
|
|
|
|
basePath?: string
|
|
|
|
sassOptions?: { [key: string]: any }
|
|
|
|
productionBrowserSourceMaps?: boolean
|
|
|
|
optimizeFonts?: boolean
|
|
|
|
|
2021-02-27 07:19:35 +01:00
|
|
|
future: {
|
2021-06-07 22:48:29 +02:00
|
|
|
/**
|
|
|
|
* @deprecated this options was moved to the top level
|
|
|
|
*/
|
|
|
|
webpack5?: false
|
2021-03-26 16:19:48 +01:00
|
|
|
strictPostcssConfiguration?: boolean
|
|
|
|
}
|
|
|
|
experimental: {
|
|
|
|
cpus?: number
|
|
|
|
plugins?: boolean
|
|
|
|
profiling?: boolean
|
|
|
|
sprFlushToDisk?: boolean
|
|
|
|
reactMode?: 'legacy' | 'concurrent' | 'blocking'
|
|
|
|
workerThreads?: boolean
|
|
|
|
pageEnv?: boolean
|
|
|
|
optimizeImages?: boolean
|
|
|
|
optimizeCss?: boolean
|
|
|
|
scrollRestoration?: boolean
|
|
|
|
stats?: boolean
|
|
|
|
externalDir?: boolean
|
|
|
|
conformance?: boolean
|
|
|
|
amp?: {
|
|
|
|
optimizer?: any
|
|
|
|
validator?: string
|
|
|
|
skipValidation?: boolean
|
|
|
|
}
|
2021-05-18 23:49:50 +02:00
|
|
|
reactRoot?: boolean
|
|
|
|
disableOptimizedLoading?: boolean
|
|
|
|
gzipSize?: boolean
|
2021-06-09 16:51:56 +02:00
|
|
|
craCompat?: boolean
|
2021-07-10 18:49:02 +02:00
|
|
|
esmExternals?: boolean | 'loose'
|
2021-07-16 11:21:44 +02:00
|
|
|
staticPageGenerationTimeout?: number
|
|
|
|
pageDataCollectionTimeout?: number
|
2021-02-27 07:19:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const defaultConfig: NextConfig = {
|
2021-07-12 23:38:57 +02:00
|
|
|
env: {},
|
2021-02-27 07:19:35 +01:00
|
|
|
webpack: null,
|
|
|
|
webpackDevMiddleware: null,
|
|
|
|
distDir: '.next',
|
2021-06-14 16:20:34 +02:00
|
|
|
cleanDistDir: true,
|
2021-02-27 07:19:35 +01:00
|
|
|
assetPrefix: '',
|
|
|
|
configOrigin: 'default',
|
|
|
|
useFileSystemPublicRoutes: true,
|
|
|
|
generateBuildId: () => null,
|
|
|
|
generateEtags: true,
|
|
|
|
pageExtensions: ['tsx', 'ts', 'jsx', 'js'],
|
|
|
|
target: 'server',
|
|
|
|
poweredByHeader: true,
|
|
|
|
compress: true,
|
|
|
|
analyticsId: process.env.VERCEL_ANALYTICS_ID || '',
|
|
|
|
images: imageConfigDefault,
|
|
|
|
devIndicators: {
|
|
|
|
buildActivity: true,
|
|
|
|
},
|
|
|
|
onDemandEntries: {
|
|
|
|
maxInactiveAge: 60 * 1000,
|
|
|
|
pagesBufferLength: 2,
|
|
|
|
},
|
|
|
|
amp: {
|
|
|
|
canonicalBase: '',
|
|
|
|
},
|
|
|
|
basePath: '',
|
|
|
|
sassOptions: {},
|
|
|
|
trailingSlash: false,
|
|
|
|
i18n: null,
|
|
|
|
productionBrowserSourceMaps: false,
|
2021-04-05 19:47:03 +02:00
|
|
|
optimizeFonts: true,
|
2021-07-12 23:38:57 +02:00
|
|
|
webpack5:
|
|
|
|
Number(process.env.NEXT_PRIVATE_TEST_WEBPACK4_MODE) > 0 ? false : undefined,
|
|
|
|
excludeDefaultMomentLocales: true,
|
|
|
|
serverRuntimeConfig: {},
|
|
|
|
publicRuntimeConfig: {},
|
|
|
|
reactStrictMode: false,
|
2021-02-27 07:19:35 +01:00
|
|
|
experimental: {
|
|
|
|
cpus: Math.max(
|
|
|
|
1,
|
|
|
|
(Number(process.env.CIRCLE_NODE_TOTAL) ||
|
|
|
|
(os.cpus() || { length: 1 }).length) - 1
|
|
|
|
),
|
|
|
|
plugins: false,
|
|
|
|
profiling: false,
|
|
|
|
sprFlushToDisk: true,
|
|
|
|
workerThreads: false,
|
|
|
|
pageEnv: false,
|
|
|
|
optimizeImages: false,
|
|
|
|
optimizeCss: false,
|
|
|
|
scrollRestoration: false,
|
|
|
|
stats: false,
|
2021-03-19 17:43:46 +01:00
|
|
|
externalDir: false,
|
2021-04-24 22:19:07 +02:00
|
|
|
reactRoot: Number(process.env.NEXT_PRIVATE_REACT_ROOT) > 0,
|
2021-06-12 13:26:47 +02:00
|
|
|
disableOptimizedLoading: false,
|
2021-05-14 16:29:49 +02:00
|
|
|
gzipSize: true,
|
2021-06-09 16:51:56 +02:00
|
|
|
craCompat: false,
|
2021-07-10 18:49:02 +02:00
|
|
|
esmExternals: false,
|
2021-07-16 11:21:44 +02:00
|
|
|
staticPageGenerationTimeout: 60,
|
|
|
|
pageDataCollectionTimeout: 60,
|
2021-02-27 07:19:35 +01:00
|
|
|
},
|
|
|
|
future: {
|
|
|
|
strictPostcssConfiguration: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export function normalizeConfig(phase: string, config: any) {
|
|
|
|
if (typeof config === 'function') {
|
|
|
|
config = config(phase, { defaultConfig })
|
|
|
|
|
|
|
|
if (typeof config.then === 'function') {
|
|
|
|
throw new Error(
|
2021-03-29 10:25:00 +02:00
|
|
|
'> Promise returned in next config. https://nextjs.org/docs/messages/promise-in-next-config'
|
2021-02-27 07:19:35 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return config
|
|
|
|
}
|