-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.mjs
158 lines (140 loc) · 4.87 KB
/
next.config.mjs
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
import nextPwa from 'next-pwa';
import runtimeCaching from 'next-pwa/cache.js';
import { withSentryConfig } from '@sentry/nextjs';
import i18nextConfig from './next-i18next.config.js';
const i18n = i18nextConfig.i18n;
const imageDomains = process.env.IMAGE_DOMAINS
? process.env.IMAGE_DOMAINS.split(',')
: null;
const imageDomainsWithOnlyHostname = [];
function getHostnameFromRegex(url) {
// run against regex
const matches = url.match(/^https?:\/\/([^/?#]+)(?:[/?#]|$)/i);
// extract hostname (will be empty string if no match is found)
return matches ? matches[1] : '';
}
if (imageDomains && Array.isArray(imageDomains)) {
imageDomains.forEach((domain) => {
const hostname = getHostnameFromRegex(domain);
if (hostname) {
imageDomainsWithOnlyHostname.push(hostname);
}
});
}
/** @type {import('next').NextConfig} */
const nextConfig = {
productionBrowserSourceMaps: true,
compress: true,
distDir: process.env.NODE_ENV === 'production' ? '.next' : '.next-dev',
reactStrictMode: false,
optimizeFonts: true,
i18n,
devIndicators: {
buildActivityPosition: 'bottom-right'
},
async rewrites() {
return [
{
source: '/script.js',
destination: 'https://umami.sireto.io/script.js'
}
];
},
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'DENY'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
}
]
}
];
},
images: {
minimumCacheTTL: 600,
formats: ['image/avif', 'image/webp'],
domains: imageDomainsWithOnlyHostname
},
env: {
BASE_DEPLOY_PATH: process.env.BASE_DEPLOY_PATH ?? '',
ELASTIC_APM_SERVER_URL: process.env.ELASTIC_APM_HOST,
ELASTIC_APM_SERVICE_NAME: process.env.ELASTIC_APM_SERVICE_NAME,
ELASTIC_APM_ENVIRONMENT: process.env.ELASTIC_APM_ENVIRONMENT,
ENABLE_BRAND_COLORS: process.env.ENABLE_BRAND_COLORS,
ENABLE_JOYRIDE_TOURS: process.env.ENABLE_JOYRIDE_TOURS,
FORM_PRIVACY_POLICY_URL: process.env.FORM_PRIVACY_POLICY_URL,
GA_MEASUREMENT_ID: process.env.GA_MEASUREMENT_ID,
MICROSOFT_CLARITY_TRACKING_CODE: process.env.MICROSOFT_CLARITY_TRACKING_CODE,
NEXT_PUBLIC_NODE_ENV: process.env.NEXT_PUBLIC_NODE_ENV ?? 'production',
NEXT_PUBLIC_WS_URL: process.env.NEXT_PUBLIC_WS_URL ?? 'ws://172.17.0.1:3001',
NEXT_PUBLIC_IMAGE_TAG: process.env.NEXT_PUBLIC_IMAGE_TAG ?? 'dev'
}
};
if (process.env.BASE_DEPLOY_PATH) {
nextConfig.assetPrefix = process.env.BASE_DEPLOY_PATH;
nextConfig.basePath = process.env.BASE_DEPLOY_PATH;
}
const withPWA = nextPwa({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
runtimeCaching,
buildExcludes: [/middleware-manifest\.json$/]
});
const nextConfigWithPWA = withPWA({
...nextConfig,
...(process.env.NODE_ENV === 'production' && {
typescript: {
ignoreBuildErrors: false
},
eslint: {
ignoreDuringBuilds: false
}
})
});
const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
dryRun: process.env.NODE_ENV !== 'production',
silent: true, // Suppresses all logs
attachStacktrace: true,
release: process.env.SENTRY_RELEASE,
url: process.env.SENTRY_URL,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
// Specify the directory containing build artifacts
assets: './**',
// Don't upload the source maps of dependencies
ignore: ['./node_modules/**']
},
debug: process.env.NEXT_PUBLIC_NODE_ENV !== 'production'
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
const nextConfigWithSentryIfEnabled =
!!process.env.SENTRY_DSN &&
!!process.env.SENTRY_URL &&
!!process.env.SENTRY_ORG &&
!!process.env.SENTRY_PROJECT &&
!!process.env.SENTRY_RELEASE
? withSentryConfig(
{ ...nextConfigWithPWA, devtool: 'source-map' },
sentryWebpackPluginOptions
)
: nextConfigWithPWA;
export default nextConfigWithSentryIfEnabled;