-
Notifications
You must be signed in to change notification settings - Fork 50
/
next.config.js
61 lines (54 loc) · 1.65 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { withSentryConfig } = require('@sentry/nextjs');
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
/* eslint-disable @typescript-eslint/no-var-requires */
const checkValidatorAvailability = async () => {
try {
const response = await fetch(`${process.env.NEXT_PUBLIC_VALIDATOR}/health`);
if (response.ok) {
return true;
} else {
return false;
}
} catch (error) {
return false;
}
};
module.exports = async (phase) => {
if (phase === 'phase-development-server') {
const isValidatorReachable = await checkValidatorAvailability();
if (!isValidatorReachable) {
console.error('Start validator server first before running next dev server.');
process.exit(1);
}
}
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const nextConfig = withBundleAnalyzer({
modularizeImports: {
'@mui/material': {
transform: '@mui/material/{{member}}',
},
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
},
rewrites: async () => {
return [
{
source: '/',
destination: '/index.html',
},
];
},
});
const sentryConfig = withSentryConfig(
nextConfig,
{ silent: true },
// tunnelRoute set to bypass adblockers.
// See: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-tunneling-to-avoid-ad-blockers.
{ hideSourcemaps: false, tunnelRoute: '/sentry-tunnel' },
);
return sentryConfig;
};