-
Notifications
You must be signed in to change notification settings - Fork 67
/
next.config.js
212 lines (198 loc) · 6 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
const TerserPlugin = require('terser-webpack-plugin')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const { i18n } = require('./next-i18next.config')
const { publicRuntimeConfig } = require('./runtime.config.js')
const path = require('path')
const { withSentryConfig } = require('@sentry/nextjs')
const basePath = ''
/**
* @type {import('next').NextConfig}
*/
const baseConfig = {
output: 'standalone',
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
basePath,
productionBrowserSourceMaps: true,
pageExtensions: ['tsx', 'ts'],
publicRuntimeConfig: publicRuntimeConfig,
sentry: {
disableServerWebpackPlugin: true,
disableClientWebpackPlugin: true,
},
webpack: function (config, { isServer, dev }) {
config.module.rules.push({
test: /\.(svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]',
},
},
})
config.optimization = {
minimize: !dev,
minimizer: [
new TerserPlugin({
minify: TerserPlugin.swcMinify,
// TODO: Figure out how to disable mangling partially without breaking the aplication.
// To test if your changes break the app or no - go to /owner/<address> page for an account that has some vaults and see if they are displayed.
terserOptions: {
mangle: false,
compress: {
dead_code: false,
},
},
}),
],
splitChunks:
!isServer && !dev
? {
chunks: 'all',
cacheGroups: {
...config.optimization.splitChunks.cacheGroups,
},
}
: {},
}
if (!isServer) {
config.resolve = {
...config.resolve,
fallback: {
fs: false,
},
}
config.plugins.push(new NodePolyfillPlugin())
}
const enableCircularDependencyPlugin = process.env.ENABLE_CIRCULAR_DEPENDENCY_PLUGIN === 'true'
if (!isServer && enableCircularDependencyPlugin) {
const CircularDependencyPlugin = require('circular-dependency-plugin')
config.plugins.push(
new CircularDependencyPlugin({
exclude: /node_modules/,
failOnError: false,
allowAsyncCycles: false,
cwd: process.cwd(),
}),
)
}
if (dev) {
const { I18NextHMRPlugin } = require('i18next-hmr/webpack')
config.plugins.push(
new I18NextHMRPlugin({
localesDir: path.resolve('./public/locales'),
}),
)
}
return config
},
i18n: Object.assign(i18n, {
...i18n,
localeDetection: false, // set to false because of recent update https://github.com/vercel/next.js/issues/55648
}),
async redirects() {
return [
{
source: '/multiply/aave/open/:strategy*',
destination: '/multiply/aave/v2/open/:strategy*',
permanent: true,
},
{
source: '/earn/aave/open/:strategy*',
destination: '/earn/aave/v2/open/:strategy*',
permanent: true,
},
{
source: '/aave/:vault(0x[a-fA-F0-9]{40}$)*',
destination: '/aave/v2/:vault*',
permanent: true,
},
{
source: '/aave/:vault(\\d{1,})*',
destination: '/aave/v2/:vault*',
permanent: true,
},
{
source: '/:type/aave/:version/open/:strategy*',
destination: '/ethereum/aave/:version/:type/:strategy*',
permanent: false,
},
{
source: '/aave/:version/:vault*',
destination: '/ethereum/aave/:version/:vault*',
permanent: false,
},
{
source: '/careers(.*)',
destination: 'https://oasisapp.workable.com/',
permanent: true,
},
{
source: '/:vault(\\d+)',
destination: '/ethereum/maker/:vault*',
permanent: false,
},
{
source: '/owner/:address(\\d{1,})*',
destination: '/portfolio/:address*',
permanent: true,
},
]
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubdomains; preload',
},
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'X-Frame-Options', value: 'ALLOW' },
{ key: 'X-XSS-Protection', value: '1; mode=block' },
{ key: 'Referrer-Policy', value: 'same-origin' },
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type' },
],
},
]
},
transpilePackages: ['@lifi/widget', '@lifi/wallet-management', 'ramda'],
experimental: {
largePageDataBytes: 280 * 1024, // 280 KB. The default one is 128 KB, but we have a lot of that kind of errors, so we increase it.
},
}
module.exports = withBundleAnalyzer(baseConfig)
if (process.env.SENTRY_AUTH_TOKEN !== undefined && process.env.SENTRY_AUTH_TOKEN !== '') {
module.exports = withSentryConfig(
module.exports,
{
org: 'oazo-apps',
project: 'oazo-apps',
url: 'https://sentry.io/',
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: '/monitoring',
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
},
)
}