-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
188 lines (176 loc) · 6.38 KB
/
Copy pathnext.config.ts
File metadata and controls
188 lines (176 loc) · 6.38 KB
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
import type { NextConfig } from 'next';
import bundleAnalyzer from '@next/bundle-analyzer';
import withPlugins from 'next-compose-plugins';
import withOptimizedImages from 'next-optimized-images';
import withPWA from 'next-pwa';
if (process.env.secrets && process.env.secrets !== '{}') {
process.env.JWT_SECRET = JSON.parse(process.env.secrets).JWT_SECRET;
process.env.OKTA_CLIENT_SECRET = JSON.parse(
process.env.secrets,
).OKTA_CLIENT_SECRET;
process.env.API_OAUTH_CLIENT_SECRET = JSON.parse(
process.env.secrets,
).API_OAUTH_CLIENT_SECRET;
process.env.ROLLBAR_SERVER_ACCESS_TOKEN = JSON.parse(
process.env.secrets,
).ROLLBAR_SERVER_ACCESS_TOKEN;
}
const prod = process.env.NODE_ENV === 'production';
if (prod && !process.env.JWT_SECRET) {
throw new Error('JWT_SECRET environment variable is not set');
}
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
const config: NextConfig = {
env: {
DEVELOPMENT_ENV: process.env.DEVELOPMENT_ENV ?? 'false',
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
JWT_SECRET: process.env.JWT_SECRET ?? 'development-key',
API_URL: process.env.API_URL ?? 'https://api.stage.mpdx.org/graphql',
REST_API_URL:
process.env.REST_API_URL ?? 'https://api.stage.mpdx.org/api/v2/',
OAUTH_URL: process.env.OAUTH_URL ?? 'https://auth.stage.mpdx.org',
CLIENT_ID: process.env.CLIENT_ID ?? '4027334344069527005',
CLIENT_SECRET: process.env.CLIENT_SECRET,
AUTH_PROVIDER: process.env.AUTH_PROVIDER ?? 'OKTA',
OKTA_CLIENT_ID: process.env.OKTA_CLIENT_ID ?? '0oa1n0gjoy3j5Ycdg0h8',
OKTA_CLIENT_SECRET: process.env.OKTA_CLIENT_SECRET,
OKTA_ISSUER: process.env.OKTA_ISSUER ?? 'https://signon.okta.com',
OKTA_SIGNOUT_REDIRECT_URL:
process.env.OKTA_SIGNOUT_REDIRECT_URL ?? 'http://localhost:3000',
API_OAUTH_CLIENT_ID:
process.env.API_OAUTH_CLIENT_ID ??
'3nxoth_gyetHdpjKp2WYkND1PUQlvYcjXQHW9ZdDxq4',
API_OAUTH_CLIENT_SECRET: process.env.API_OAUTH_CLIENT_SECRET,
API_OAUTH_ISSUER_AUTHORIZATION_URL:
process.env.API_OAUTH_ISSUER_AUTHORIZATION_URL ??
'https://api.stage.mpdx.org/oauth/authorize',
API_OAUTH_ISSUER_TOKEN_URL:
process.env.API_OAUTH_ISSUER_TOKEN_URL ??
'https://api.stage.mpdx.org/oauth/token',
API_OAUTH_SCOPE: process.env.API_OAUTH_SCOPE ?? 'read write',
API_OAUTH_VISIBLE_NAME: process.env.API_OAUTH_VISIBLE_NAME ?? 'SSO',
GOOGLE_MAPS_API_KEY: process.env.GOOGLE_MAPS_API_KEY,
GOOGLE_TAG_MANAGER_CONTAINER_ID:
process.env.GOOGLE_TAG_MANAGER_CONTAINER_ID,
ROLLBAR_ACCESS_TOKEN: process.env.ROLLBAR_ACCESS_TOKEN,
APP_NAME: process.env.APP_NAME ?? 'MPDX',
ROLLBAR_SERVER_ACCESS_TOKEN: process.env.ROLLBAR_SERVER_ACCESS_TOKEN,
DATADOG_APP_ID: process.env.DATADOG_APP_ID,
DATADOG_CLIENT_TOKEN: process.env.DATADOG_CLIENT_TOKEN,
DATADOG_CONFIGURED: Boolean(
process.env.NODE_ENV === 'production' &&
process.env.DATADOG_APP_ID &&
process.env.DATADOG_CLIENT_TOKEN,
).toString(),
HELPJUICE_ORIGIN: process.env.HELPJUICE_ORIGIN,
HELPJUICE_KNOWLEDGE_BASE_URL: process.env.HELPJUICE_KNOWLEDGE_BASE_URL,
HELPJUICE_PARENT_CATEGORY:
process.env.HELPJUICE_PARENT_CATEGORY ?? '434642',
HELPJUICE_CATEGORY_ID: process.env.HELPJUICE_CATEGORY_ID ?? '472031',
HELP_URL_COACHING_ACTIVITY: process.env.HELP_URL_COACHING_ACTIVITY,
HELP_URL_COACHING_APPOINTMENTS_AND_RESULTS:
process.env.HELP_URL_COACHING_APPOINTMENTS_AND_RESULTS,
HELP_URL_SETUP_FIND_ORGANIZATION:
process.env.HELP_URL_SETUP_FIND_ORGANIZATION,
ALERT_MESSAGE: process.env.ALERT_MESSAGE,
PRIVACY_POLICY_URL: process.env.PRIVACY_POLICY_URL,
TERMS_OF_USE_URL: process.env.TERMS_OF_USE_URL,
DD_ENV: process.env.DD_ENV ?? 'development',
DATA_PRIVACY_EMAIL: process.env.DATA_PRIVACY_EMAIL ?? 'dsar@cru.org',
DONATION_SERVICES_EMAIL:
process.env.DONATION_SERVICES_EMAIL ?? 'donation.services@cru.org',
DISABLE_NEW_REPORTS: process.env.DISABLE_NEW_REPORTS,
DISABLE_NS_GOAL_CALCULATOR: process.env.DISABLE_NS_GOAL_CALCULATOR,
DISABLE_MPD_GOAL_ADMIN: process.env.DISABLE_MPD_GOAL_ADMIN,
GIT_COMMIT_SHA: process.env.GIT_COMMIT_SHA,
},
// Force .page prefix on page files (ex. index.page.tsx) so generated files can be included in /pages directory without Next.js throwing build errors
pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'],
productionBrowserSourceMaps: true,
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
reactStrictMode: true,
webpack: (config) => {
config.experiments = {
...config.experiments,
topLevelAwait: true,
};
config.module.rules.push(
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
use: [
{
loader: 'graphql-tag/loader',
},
],
},
);
const imageLoaderRule = config.module.rules.find(
(rule) => rule.loader === 'next-image-loader',
);
imageLoaderRule.exclude = /\.svg$/;
config.module.rules.push(
{
test: /\.(png|jpg|gif|woff|woff2|otf|ttf|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 100000,
},
},
],
},
{
test: /\.(png|jpe?g|gif|mp3|aif)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
],
},
);
return config;
},
// @mui/x-data-grid v8's ESM build imports its own global CSS
// (@mui/x-data-grid/esm/index.css). Next.js only allows global CSS
// imports from node_modules for packages listed in transpilePackages.
transpilePackages: ['@mui/x-data-grid'],
redirects: async () => [
{
source: '/accountLists/:accountListId/settings',
destination: '/accountLists/:accountListId/settings/preferences',
permanent: true,
},
],
};
module.exports = withPlugins([
[
withPWA,
{
pwa: {
dest: 'public',
disable: !prod,
},
},
],
withOptimizedImages,
// Workaround @next/bundle-analyzer not playing nicely with next-compose-plugins
// https://github.com/cyrilwanner/next-compose-plugins/issues/26
withBundleAnalyzer(config),
]);