-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
137 lines (127 loc) · 3.62 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
const { PHASE_PRODUCTION_BUILD, PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const color = require('cli-color');
const { validateData } = require('./data/validate');
const {
OVERRIDE_NODE_ENV = '',
FB_PIXEL_ID,
GOOGLE_ANALYTICS_ID,
// Default to current date if not set
HIGHSCHOOL_FORM_ACTIVE_UNTIL = new Date().toISOString(),
HIGHSCHOOL_FORM_RESPONSES_NAME = '__TAB_NAME_NOT_SET__',
} = process.env;
const hsFormActiveUntil = new Date(HIGHSCHOOL_FORM_ACTIVE_UNTIL);
module.exports = (phase, { defaultConfig }) => {
const isHsFormActive = hsFormActiveUntil > new Date();
console.info(color.magentaBright.bold('\nValidating... '));
if (
!process.env.GITHUB_ACTION &&
[PHASE_PRODUCTION_BUILD, PHASE_DEVELOPMENT_SERVER].includes(phase)
) {
checkEnvVars([
'MAILCHIMP_API_KEY',
'MAILCHIMP_AUDIENCE_ID',
'GREENLIGHT_API_ENDPOINT',
'SIGNUP_API_ENDPOINT',
'GOOGLE_SERVICE_ACCOUNT',
'HIGHSCHOOL_FORM_RESPONSES_ID',
'WUFOO_HOST',
'WUFOO_TOKEN',
'WUFOO_CONTACT_FORM_ID',
'GOOGLE_EVENTS_CALENDAR_ID',
'HIGHSCHOOL_FORM_RESPONSES_NAME',
'GOOGLE_ANALYTICS_ID',
]);
validateData();
}
if (PHASE_DEVELOPMENT_SERVER === phase) {
const port = process.env.PORT;
console.info(color.blueBright.bold('\nhttp://localhost:' + (port ?? '3000') + '\n'));
}
/**
* @type {import('next').NextConfig}
*/
const config = {
...defaultConfig,
reactStrictMode: true,
compiler: {
styledComponents: {
pure: true,
displayName: true,
},
},
env: {
OVERRIDE_NODE_ENV: OVERRIDE_NODE_ENV || '',
FB_PIXEL_ID,
HIGHSCHOOL_FORM_ACTIVE_UNTIL,
HIGHSCHOOL_FORM_RESPONSES_NAME,
GOOGLE_ANALYTICS_ID: GOOGLE_ANALYTICS_ID || '',
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'storage.googleapis.com',
},
],
},
async redirects() {
return [
{
source: '/info-session',
destination: '/programs/workforce/infoSession',
permanent: true,
},
{
source: '/infoSession',
destination: '/programs/workforce/infoSession',
permanent: true,
},
{
source: `/noladevs`,
destination: '/getInvolved/noladevs',
permanent: false,
},
{
source: `/donate`,
destination: '/getInvolved/donate',
permanent: false,
},
// High School Program
{
source: '/high-school',
destination: '/programs/highschool',
permanent: true,
},
{
source: '/highschool',
destination: '/programs/highschool',
permanent: true,
},
/**
* High School Application - `/programs/highschool/apply`
* - When high school form is available, set env variable 'HIGHSCHOOL_FORM_ACTIVE' to 'true' otherwise 'false'
*/
!isHsFormActive && {
source: '/programs/highschool/apply',
destination: '/programs/highschool',
permanent: false,
},
{
source: '/privacy',
destination: '/privacyPolicy',
permanent: true,
},
// Filter out false/undefined/null routes
].filter(Boolean);
},
};
return config;
};
function checkEnvVars(requiredVars) {
for (const requiredVar of requiredVars) {
if (!process.env[requiredVar]) {
throw new Error(`"${requiredVar}" environment variable not found.`);
}
}
console.info(color.green(' ✓'), 'Validating credentials and data');
}