forked from hacpy/oasis-borrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
122 lines (116 loc) · 4.24 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
const withSass = require('@zeit/next-sass')
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)$/,
})
const withPWA = require('next-pwa')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const MomentLocalesPlugin = require('moment-locales-webpack-plugin')
const { i18n } = require('./next-i18next.config')
const isProduction = process.env.NODE_ENV === 'production'
const basePath = ''
module.exports = withBundleAnalyzer(
withPWA(
withMDX(
withSass({
basePath,
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// We do ythis for now to allow for staging deployments during the
// active development phase and are planning to remove this later
// !! WARN !!
ignoreBuildErrors: isProduction,
},
cssModules: true,
pageExtensions: ['mdx', 'tsx'],
publicRuntimeConfig: {
// Will be available on both server and client
buildHash: process.env.COMMIT_SHA,
buildDate: Date.now(),
apiHost: process.env.API_HOST,
basePath,
mixpanelEnv: process.env.MIXPANEL_ENV,
mixpanelAPIKey: process.env.MIXPANEL_KEY,
adRollAdvId: process.env.ADROLL_ADV_ID,
adRollPixId: process.env.ADROLL_PIX_ID,
useTermsOfService: process.env.USE_TERMS_OF_SERVICE === '1',
showBuildInfo: process.env.SHOW_BUILD_INFO === '1',
infuraProjectId: process.env.INFURA_PROJECT_ID,
etherscanAPIKey: process.env.ETHERSCAN_API_KEY,
exchangeAddress:
process.env.USE_DUMMY === '1' ? process.env.DUMMY_EXCHANGE : process.env.EXCHANGE,
multiplyProxyActions: process.env.MULTIPLY_PROXY_ACTIONS,
},
webpack: function (config, { isServer }) {
// 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.
config.optimization.minimizer[0].options.terserOptions.mangle = false
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]',
},
},
})
// Moment.js locales take up a lot of space, so it's good to remove unused ones. "en" is there by default and can not be removed
config.plugins.push(new MomentLocalesPlugin({ localesToKeep: ['es', 'pt'] }))
if (!isServer) {
config.node = {
fs: 'empty',
}
}
if (!isProduction) {
config.watch = true
// Don't ignore all node modules.
config.watchOptions.ignored = config.watchOptions.ignored.filter(
(ignore) => !ignore.toString().includes('node_modules'),
)
// Ignore all node modules except those here.
config.watchOptions.ignored = [
...config.watchOptions.ignored,
/node_modules([\\]+|\/)+(?!@oasisdex)/,
/\@oasisdex([\\]+|\/)node_modules/,
]
}
return config
},
pwa: {
disable: process.env.NODE_ENV !== 'production',
register: process.env.NODE_ENV === 'production',
dest: 'public',
},
i18n,
async redirects() {
return [
{
source: '/borrow',
destination: '/',
permanent: true,
},
{
source: '/borrow/:slug*',
destination: '/:slug*',
permanent: true,
},
{
source: '/dashboard',
destination: '/daiwallet/dashboard',
permanent: true,
},
{
source: '/(0x[a-fA-F0-9]{40}.*)',
destination: '/daiwallet/dashboard',
permanent: true,
},
]
},
}),
),
),
)