-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathnext.config.js
162 lines (157 loc) · 4.39 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
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
// GNU AFFERO GENERAL PUBLIC LICENSE Version 3. Copyright (C) 2022 DAO DAO Contributors.
// See the "LICENSE" file in the root directory of this package for more copyright information.
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const withInterceptStdout = require('next-intercept-stdout')
const { withSentryConfig } = require('@sentry/nextjs')
/** @type {import("@sentry/nextjs").SentryWebpackPluginOptions} */
const sentryWebpackPluginOptions = {
silent: true,
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
const { i18n } = require('./next-i18next.config')
/** @type {import("next").NextConfig} */
const config = {
transpilePackages: [
'@dao-dao/stateless',
'@dao-dao/utils',
'@dao-dao/state',
'@dao-dao/stateful',
'@dao-dao/i18n',
'@dao-dao/types',
'@cosmos-kit/web3auth',
'chartjs-adapter-date-fns',
'chartjs-plugin-annotation',
],
// Because @cosmos-kit/web3auth uses a Worker ESM import.
experimental: {
esmExternals: 'loose',
// Increase (to 1 MB) to allow for react-query pre-fetched hydration.
largePageDataBytes: 1 * 1024 * 1024,
},
webpack: (config) => {
// @cosmos-kit/web3auth uses eccrypto, which uses `stream`. This needs to be
// polyfilled.
config.resolve.alias['stream'] = 'stream-browserify'
return config
},
i18n,
/*
The reactStrictMode flag is set to false
to allow for the proposal JSON editor to show.
*/
reactStrictMode: false,
productionBrowserSourceMaps: true,
eslint: {
dirs: [
'atoms',
'components',
'pages',
'selectors',
'services',
'types',
'util',
'server',
],
},
redirects: async () => [
{
source: '/starred',
destination: '/',
permanent: false,
},
{
source: '/home',
destination: '/',
permanent: false,
},
{
source: '/inbox/:slug*',
destination: '/notifications/:slug*',
permanent: false,
},
// Redirect legacy multisigs (legacy DAOs redirected in
// makeGetDaoStaticProps function).
{
source: '/multisig/:slug*',
destination:
process.env.NEXT_PUBLIC_LEGACY_URL_PREFIX + '/multisig/:slug*',
permanent: false,
},
{
source: '/me/:slug*',
destination: '/:slug*',
permanent: false,
},
{
source: '/tx',
destination: '/actions',
permanent: false,
},
// Redirect all gov subpages to the dao subpage, but leave /gov alone.
{
source: '/gov/:chain/:slug*',
destination: '/dao/:chain/:slug*',
permanent: false,
},
// Rename Neutron proposal IDs from starting with N to A.
{
source:
'/dao/neutron1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrstdxvff/proposals/N:slug',
destination:
'/dao/neutron1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrstdxvff/proposals/A:slug',
permanent: true,
},
// Rename Neutron proposal IDs from starting with P to C.
{
source:
'/dao/neutron1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrstdxvff/proposals/P:slug',
destination:
'/dao/neutron1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrstdxvff/proposals/C:slug',
permanent: true,
},
],
// Only upload source maps to Sentry in CI action when token is provided.
sentry: {
disableServerWebpackPlugin:
process.env.CI !== 'true' || !process.env.SENTRY_AUTH_TOKEN,
disableClientWebpackPlugin:
process.env.CI !== 'true' || !process.env.SENTRY_AUTH_TOKEN,
},
images: {
unoptimized: true,
domains: [
'ipfs.stargaze.zone',
'ipfs-gw.stargaze-apis.com',
'i.stargaze-apis.com',
'nftstorage.link',
'ipfs.daodao.zone',
'img-proxy.daodao.zone',
'raw.githubusercontent.com',
],
},
modularizeImports: {
'@mui/material': {
transform: '@mui/material/{{member}}',
},
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
},
}
module.exports = withSentryConfig(
withBundleAnalyzer(
withInterceptStdout(
config,
// Silence Recoil duplicate warnings on dev.
(text) =>
process.env.NODE_ENV === 'development' &&
text.includes('Expectation Violation: Duplicate atom key')
? ''
: text
)
),
sentryWebpackPluginOptions
)