-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathnext.config.mjs
74 lines (70 loc) · 2.57 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
// @ts-check
import { withSentryConfig } from '@sentry/nextjs';
import { LANGUAGES } from './src/config.mjs';
const osmappVersion = process.env.npm_package_version;
const commitHash = (process.env.VERCEL_GIT_COMMIT_SHA || '').substring(0, 7);
const commitMessage = process.env.VERCEL_GIT_COMMIT_MESSAGE || 'dev';
const sentryRelease = `${osmappVersion}-${commitHash}-${commitMessage.substring(0, 10)}`;
const rewrites = async () => {
return {
beforeFiles: [],
afterFiles: [
{
source: '/:coords([-.0-9]+,[-.0-9]+)',
destination: '/feature/:coords',
},
{
source: '/:shortener([A-Za-z0-9]+[nwr])',
destination: '/feature/:shortener',
},
{
source: '/node/:path*',
destination: '/feature/node/:path*',
},
{
source: '/way/:path*',
destination: '/feature/way/:path*',
},
{
source: '/relation/:path*',
destination: '/feature/relation/:path*',
},
],
fallback: [
// Experiment with static SSR 404:
// - On vercel these routing rules are applied before passing the request to backend
// This way we can try to optimize number of paid function exectuions and leave pretty urls.
// - It works correctly only on Vercel, on dev internal 404 may be rendered.
// - WARNING: unfortunately I wasn't able to send HTTP statu 404, so the page just have meta-equiv=noindex
{
source: '/:path*',
destination: `/404.html`,
},
],
};
};
/** @type {import('next').NextConfig} */
const nextConfig = {
compiler: {
emotion: true,
},
output: process.env.NEXTJS_OUTPUT || undefined,
env: { osmappVersion, sentryRelease },
i18n: {
locales: ['default', ...Object.keys(LANGUAGES)], // we let next only handle URL, but chosen locale is in getServerIntl()
defaultLocale: 'default',
localeDetection: false,
},
rewrites,
};
export default withSentryConfig(nextConfig, {
org: 'osmapp', // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
project: 'osmapp',
silent: !process.env.CI,
widenClientFileUpload: true, // Upload a larger set of source maps for prettier stack traces (increases build time)
reactComponentAnnotation: { enabled: true }, // Automatically annotate React components to show their full name in breadcrumbs and session replay
// tunnelRoute: '/monitoring',
hideSourceMaps: false,
disableLogger: true, // Automatically tree-shake Sentry logger statements to reduce bundle size
automaticVercelMonitors: true, // https://vercel.com/docs/cron-jobs
});