forked from solana-foundation/explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
91 lines (83 loc) · 3.24 KB
/
next.config.mjs
File metadata and controls
91 lines (83 loc) · 3.24 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
import { withBotId } from 'botid/next/config';
import { withSentryConfig } from '@sentry/nextjs';
import path from 'path';
import { fileURLToPath } from 'url';
import { createSentryBuildConfig } from './sentry/config.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const ADDRESS_ALIASES = ['account', 'accounts', 'addresses'];
const TX_ALIASES = ['txs', 'txn', 'txns', 'transaction', 'transactions'];
const SUPPLY_ALIASES = ['accounts', 'accounts/top'];
/** @type {import('next').NextConfig} */
const nextConfig = {
// Use separate build directory for dev server to avoid conflicts with production builds
distDir: process.env.NODE_ENV === 'production' ? '.next' : '.next-dev',
experimental: {
// FIXME: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
missingSuspenseWithCSRBailout: false,
},
images: {
remotePatterns: [
{
hostname: 'raw.githubusercontent.com',
pathname: '/solana-labs/token-list/main/assets/**',
port: '',
protocol: 'https',
},
],
},
async headers() {
const seoFileHeaders = [
{
key: 'Cache-Control',
value: 'public, max-age=3600, stale-while-revalidate=86400',
},
];
return [
{ source: '/robots.txt', headers: seoFileHeaders },
{ source: '/sitemap.xml', headers: seoFileHeaders },
{ source: '/default-sitemap.xml', headers: seoFileHeaders },
{ source: '/accounts-sitemap.xml', headers: seoFileHeaders },
];
},
async redirects() {
return [
// Leave this above `ADDRESS_ALIASES`, since it also provides an alias for `/accounts`.
...SUPPLY_ALIASES.map(oldRoot => ({
destination: '/supply',
permanent: true,
source: '/' + oldRoot,
})),
...ADDRESS_ALIASES.flatMap(oldRoot =>
[':address', ':address/:tab'].map(path => ({
destination: '/' + ['address', path].join('/'),
permanent: true,
source: '/' + [oldRoot, path].join('/'),
})),
),
...TX_ALIASES.map(oldRoot => ({
destination: '/' + ['tx', ':signature'].join('/'),
permanent: true,
source: '/' + [oldRoot, ':signature'].join('/'),
})),
{
destination: '/address/:address',
permanent: true,
source: '/address/:address/history',
},
];
},
webpack: (config, { isServer }) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
borsh: path.resolve(__dirname, 'node_modules/borsh'), // force legacy version
};
if (!isServer) {
// Fixes npm packages that depend on `fs` module like `@project-serum/anchor`.
config.resolve.fallback.fs = false;
}
return config;
},
};
/// Add wrapper to track errors with Sentry and BotID for bot protection
export default withBotId(withSentryConfig(nextConfig, createSentryBuildConfig()));