-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
242 lines (236 loc) · 6.91 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/* eslint-disable @typescript-eslint/no-var-requires, import/order */
// const bundleAnalyser = require('@next/bundle-analyzer');
/*
* next-transpile-modules is necessary because:
* - Global CSS cannot be imported from within node_modules.
* Why: https://nextjs.org/docs/messages/css-npm
* RFC: https://github.com/vercel/next.js/discussions/27953
*/
const nextTranspileModules = require('next-transpile-modules');
const path = require('path');
// const withBundleAnalyzer = bundleAnalyser({
// enabled: process.env.ANALYZE === 'true',
// });
const withTM = nextTranspileModules(['ky-universal']);
/** @type {import("next").NextConfig} */
// module.exports = withBundleAnalyzer(
module.exports = withTM({
i18n: {
locales: ['nl', 'en'],
defaultLocale: 'nl',
localeDetection: false,
},
// https://stackoverflow.com/questions/71847778/why-my-nextjs-component-is-rendering-twice
// Disabling react 18 strict mode, otherwise the zendesk widget is rendered twice
reactStrictMode: false,
experimental: {
/**
* Necessary to prevent errors like:
* - Module not found: ESM packages (lodash-es) need to be imported.
* Use 'import' to reference the package instead.
* Solution: https://nextjs.org/docs/messages/import-esm-externals
*/
esmExternals: 'loose',
/**
* Ignore warnings about big page data, since we load translations like that
* https://meemoo.atlassian.net/browse/ARC-1932
*/
largePageDataBytes: 300 * 1000,
},
webpack: (config, options) => {
// Required for ky-universal top level await used in admin core inside the api service
config.experiments = { topLevelAwait: true, layers: true };
// https://stackoverflow.com/a/68098547/373207
config.resolve.fallback = { fs: false, path: false };
// Fix issues with react-query:
// https://github.com/TanStack/query/issues/3595#issuecomment-1276468579
if (options.isServer) {
config.externals = ['@tanstack/react-query', 'use-query-params', ...config.externals];
}
config.resolve.alias = {
...config.resolve.alias,
['@tanstack/react-query']: path.resolve('./node_modules/@tanstack/react-query'),
['use-query-params']: path.resolve('./node_modules/use-query-params'),
['react-select']: path.resolve('./node_modules/react-select'),
['react-select/creatable']: path.resolve('./node_modules/react-select/creatable'),
['react-select/async']: path.resolve('./node_modules/react-select/async'),
['react-popper']: path.resolve('./node_modules/react-popper'),
['react-hook-form']: path.resolve('./node_modules/react-hook-form'),
['react-table']: path.resolve('./node_modules/react-table'),
['react-datepicker']: path.resolve('./node_modules/react-datepicker'),
['react-page-split']: path.resolve('./node_modules/react-page-split'),
['lodash$']: path.resolve('./node_modules/lodash-es'),
};
return config;
},
typescript: {
tsconfigPath: './tsconfig.build.json',
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**.viaa.be',
},
{
protocol: 'https',
hostname: '**.hetarchief.be',
},
],
},
productionBrowserSourceMaps: true, // process.env.DEBUG_TOOLS === 'true',
publicRuntimeConfig: {
NEXT_TELEMETRY_DISABLED: process.env.NEXT_TELEMETRY_DISABLED,
NODE_ENV: process.env.NODE_ENV,
PORT: process.env.PORT,
CLIENT_URL: process.env.CLIENT_URL,
SSUM_EDIT_ACCOUNT_URL: process.env.SSUM_EDIT_ACCOUNT_URL,
PROXY_URL: process.env.PROXY_URL,
DEBUG_TOOLS: process.env.DEBUG_TOOLS,
ZENDESK_KEY: process.env.ZENDESK_KEY,
FLOW_PLAYER_TOKEN: process.env.FLOW_PLAYER_TOKEN,
FLOW_PLAYER_ID: process.env.FLOW_PLAYER_ID,
GOOGLE_TAG_MANAGER_ID: process.env.GOOGLE_TAG_MANAGER_ID,
ENABLE_GOOGLE_INDEXING: process.env.ENABLE_GOOGLE_INDEXING,
},
async headers() {
if (process.env.ENABLE_GOOGLE_INDEXING === 'false') {
return [
{
source: '/',
headers: [
{
key: 'X-Robots-Tag',
value: 'noindex, nofollow, noarchive',
},
],
},
{
source: '/(.*)',
headers: [
{
key: 'X-Robots-Tag',
value: 'noindex, nofollow, noarchive',
},
],
},
];
}
return [];
},
async redirects() {
return [
// CP admin redirects
{
source: '/beheer/aanvragen',
destination: '/beheer/toegangsaanvragen',
permanent: true,
},
// Admin redirects
{
// Only the dutch redirect, since that was the only language that existed at the time
source: '/admin/bezoekersruimtesbeheer/aanvragen',
destination: `/beheer/toegangsaanvragen`,
permanent: true,
},
{
source: '/admin/content',
destination: `/admin/content-paginas`,
permanent: true,
},
{
source: '/admin/content/:path*',
destination: `/admin/content-paginas/:path*`,
permanent: true,
},
// Account redirects
{
// Only the dutch redirect, since that was the only language that existed at the time
source: '/account',
destination: '/account/mijn-profiel',
permanent: true,
},
{
// Only the dutch redirect, since that was the only language that existed at the time
source: '/account/mijn-historiek',
destination: '/account/mijn-bezoek-historiek',
permanent: true,
},
{
// Only the dutch redirect, since that was the only language that existed at the time
source: '/bladwijzers',
destination: '/account/mijn-mappen/favorieten',
permanent: true,
},
{
source: '/account/mijn-mappen',
destination: '/account/mijn-mappen/favorieten',
permanent: true,
},
{
source: '/account/my-folders',
destination: '/account/my-folders/favorites',
permanent: true,
},
{
// Only the dutch redirect, since that was the only language that existed at the time
source: '/gebruiker/profiel',
destination: 'account/mijn-profiel',
permanent: true,
},
// General redirects
{
source: '/home',
destination: '/',
permanent: true,
},
{
// Only the dutch redirect, since that was the only language that existed at the time
source: '/handleiding',
destination: '/vragen',
permanent: true,
},
// Search redirects
{
source: '/catalog',
destination: '/zoeken',
permanent: true,
},
{
source: '/catalog/:pid',
destination: '/zoeken?zoekterm=:pid',
permanent: true,
},
{
source: '/catalog\\?f%5Bmedia_type_s\\%5D\\%5B\\%5D=video',
destination: '/zoeken',
permanent: true,
},
{
source: '/catalog\\?utf8=\\%E2\\%9C\\%93&q=&search_field=all_fields&search_field=advanced&all_fields=hond',
destination: '/zoeken',
permanent: true,
},
{
source: '/amsab/:slug',
destination: '/zoeken/amsab-isg/:slug',
permanent: true,
},
{
source: '/amsab-isg/:slug',
destination: '/zoeken/amsab-isg/:slug',
permanent: true,
},
{
source: '/advn/:slug',
destination: '/zoeken/advn/:slug',
permanent: true,
},
{
source: '/kadoc/:slug',
destination: '/zoeken/kadoc/:slug',
permanent: true,
},
];
},
});