-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
config-shared.ts
144 lines (135 loc) · 3.36 KB
/
config-shared.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import os from 'os'
import { Header, Redirect, Rewrite } from '../../lib/load-custom-routes'
import { imageConfigDefault } from './image-config'
export type DomainLocales = Array<{
http?: true
domain: string
locales?: string[]
defaultLocale: string
}>
export type NextConfig = { [key: string]: any } & {
i18n?: {
locales: string[]
defaultLocale: string
domains?: DomainLocales
localeDetection?: false
} | null
headers?: () => Promise<Header[]>
rewrites?: () => Promise<
| Rewrite[]
| {
beforeFiles: Rewrite[]
afterFiles: Rewrite[]
fallback: Rewrite[]
}
>
redirects?: () => Promise<Redirect[]>
trailingSlash?: boolean
future: {
strictPostcssConfiguration?: boolean
excludeDefaultMomentLocales?: boolean
webpack5?: boolean
}
experimental: {
cpus?: number
plugins?: boolean
profiling?: boolean
sprFlushToDisk?: boolean
reactMode?: 'legacy' | 'concurrent' | 'blocking'
workerThreads?: boolean
pageEnv?: boolean
optimizeImages?: boolean
optimizeCss?: boolean
scrollRestoration?: boolean
scriptLoader?: boolean
stats?: boolean
externalDir?: boolean
serialWebpackBuild?: boolean
babelMultiThread?: boolean
conformance?: boolean
amp?: {
optimizer?: any
validator?: string
skipValidation?: boolean
}
turboMode: boolean
eslint?: boolean
reactRoot: boolean
enableBlurryPlaceholder: boolean
}
}
export const defaultConfig: NextConfig = {
env: [],
webpack: null,
webpackDevMiddleware: null,
distDir: '.next',
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,
optimizeFonts: true,
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,
scriptLoader: false,
stats: false,
externalDir: false,
serialWebpackBuild: false,
turboMode: false,
eslint: false,
reactRoot: Number(process.env.NEXT_PRIVATE_REACT_ROOT) > 0,
enableBlurryPlaceholder: false,
},
future: {
strictPostcssConfiguration: false,
excludeDefaultMomentLocales: false,
webpack5: Number(process.env.NEXT_PRIVATE_TEST_WEBPACK5_MODE) > 0,
},
serverRuntimeConfig: {},
publicRuntimeConfig: {},
reactStrictMode: false,
}
export function normalizeConfig(phase: string, config: any) {
if (typeof config === 'function') {
config = config(phase, { defaultConfig })
if (typeof config.then === 'function') {
throw new Error(
'> Promise returned in next config. https://nextjs.org/docs/messages/promise-in-next-config'
)
}
}
return config
}