-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnext.config.js
106 lines (100 loc) · 2.69 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
/* eslint-disable node/no-process-env */
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { apiFetch } = require('@codeday/topo/utils');
module.exports = {
swcMinify: true,
eslint: {
ignoreDuringBuilds: true,
},
webpack: (config, { isServer }) => {
// eslint-disable-next-line node/no-process-env
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (entries['main.js'] && !entries['main.js'].includes('./src/polyfills.js')) {
entries['main.js'].unshift('./src/polyfills.js');
}
return entries;
};
if (process.env.ANALYZE) {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true,
}),
);
}
return config;
},
images: {
domains: ['f2.codeday.org'],
},
async redirects() {
const { cms } = await apiFetch('{ cms { regions { items { webname aliases } } } }');
const webnames = (cms && cms.regions && cms.regions.items ? cms.regions.items : []).flatMap((r) => [
r.webname,
...(r.aliases || []),
]);
const staticRedirects = [
{
source: '/privacy/controls',
destination: '/f/data-controls',
permanent: false,
},
{
source: '/conduct/report',
destination: '/f/conduct-report',
permanent: false,
},
{
source: '/volunteer/purchase',
destination: '/f/purchasing',
permanent: false,
},
{
source: '/volunteer/paragon',
destination: '/f/paragon',
permanent: false,
},
{
source: '/volunteer/swag',
destination: '/f/swag',
permanent: false,
},
{
source: '/organize',
destination: 'https://event.codeday.org/organize',
permanent: false,
},
{
source: '/volunteers',
destination: '/volunteer',
permanent: false,
},
];
return [
...staticRedirects,
...webnames.map((webname) => ({
source: `/${webname}`,
destination: `https://event.codeday.org/${webname}`,
permanent: false,
})),
];
},
serverRuntimeConfig: {
stripe: {
secretKey: process.env.STRIPE_SECRET_KEY,
},
postmark: {
serverToken: process.env.POSTMARK_SERVER_TOKEN,
},
airtable: {
token: process.env.AIRTABLE_TOKEN,
base: process.env.AIRTABLE_BASE,
},
clear_gql: {
token: process.env.CLEAR_TOKEN,
},
},
};