-
Notifications
You must be signed in to change notification settings - Fork 102
/
next.config.js
142 lines (135 loc) · 3.67 KB
/
next.config.js
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
import { withPayload } from '@payloadcms/next/withPayload'
import path from 'path'
import { fileURLToPath } from 'node:url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import { redirects } from './redirects.js'
import bundleAnalyzer from '@next/bundle-analyzer'
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
const localhost = process.env.NEXT_PUBLIC_IS_LIVE
? []
: [
{
protocol: 'http',
hostname: 'localhost',
port: '3000',
},
{
protocol: 'http',
hostname: 'local.payloadcms.com',
port: '3000',
},
{
protocol: 'http',
hostname: 'cms.local.payloadcms.com',
port: '8000',
},
{
protocol: 'http',
hostname: 'cms.local.payloadcms.com',
port: '8001',
},
]
const nextConfig = withBundleAnalyzer({
eslint: {
ignoreDuringBuilds: true,
},
reactStrictMode: true,
images: {
minimumCacheTTL: 60 * 60 * 24 * 365, // 1 year,
remotePatterns: [
...localhost,
{
protocol: 'https',
hostname: 'cms.payloadcms.com',
port: '',
},
{
protocol: 'https',
hostname: 'cloud-api.payloadcms.com',
port: '',
},
{
protocol: 'https',
hostname: 'cms.local.payloadcms.com',
port: '',
},
{
protocol: 'https',
hostname: 'stage.cms.payloadcms.com',
port: '',
},
{
protocol: 'https',
hostname: 'cdn.discordapp.com',
port: '',
},
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
port: '',
},
{
protocol: 'https',
hostname: 'img.youtube.com',
port: '',
},
{
protocol: 'https',
hostname: process.env.BLOB_STORE_ID,
},
].filter(Boolean),
},
sassOptions: {
silenceDeprecations: ['legacy-js-api', 'import'], // https://github.com/vercel/next.js/issues/71638
},
webpack: config => {
const configCopy = { ...config }
configCopy.resolve = {
...config.resolve,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
extensionAlias: {
'.js': ['.ts', '.js', '.tsx', '.jsx'],
'.mjs': ['.mts', '.mjs'],
},
alias: {
...config.resolve.alias,
'@scss': path.resolve(dirname, './src/css/'),
'@components': path.resolve(dirname, './src/components.js'),
'@cloud': path.resolve(dirname, './src/app/cloud'),
'@forms': path.resolve(dirname, './src/forms'),
'@blocks': path.resolve(dirname, './src/blocks'),
'@providers': path.resolve(dirname, './src/providers'),
'@icons': path.resolve(dirname, './src/icons'),
'@utilities': path.resolve(dirname, './src/utilities'),
'@types': path.resolve(dirname, './payload-types.ts'),
'@graphics': path.resolve(dirname, './src/graphics'),
'@graphql': path.resolve(dirname, './src/graphql'),
// IMPORTANT: the next lines are for development only
// keep them commented out unless actively developing local react modules
// modify their paths according to your local directory
// "payload-admin-bar": path.join(dirname, "../payload-admin-bar"),
},
}
return configCopy
},
redirects,
async headers() {
const headers = []
if (!process.env.NEXT_PUBLIC_IS_LIVE) {
headers.push({
headers: [
{
key: 'X-Robots-Tag',
value: 'noindex',
},
],
source: '/:path*',
})
}
return headers
},
})
export default withPayload(nextConfig)