forked from OasisDEX/oasis-borrow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
145 lines (137 loc) · 4.54 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
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)$/,
options: {
providerImportSource: '@mdx-js/react',
},
})
const withPWA = require('next-pwa')
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 MomentLocalesPlugin = require('moment-locales-webpack-plugin')
const { i18n } = require('./next-i18next.config')
const { withSentryConfig } = require('@sentry/nextjs')
const { publicRuntimeConfig } = require('./runtime.config.js')
const isProduction = process.env.NODE_ENV === 'production'
const basePath = ''
const conf = withBundleAnalyzer(
withPWA(
withMDX({
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,
},
productionBrowserSourceMaps: true,
cssModules: true,
pageExtensions: ['mdx', 'tsx'],
publicRuntimeConfig: publicRuntimeConfig,
webpack: function (config, { isServer }) {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]',
},
},
})
if (isProduction) {
}
config.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
// 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,
},
}),
],
}
// 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.resolve = {
...config.resolve,
fallback: {
fs: false,
},
}
config.plugins.push(new NodePolyfillPlugin())
}
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: ['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/:slug(.{1,})', // wildcard redirect `:slug*` was causing an infinite redirect loop
destination: '/:slug',
permanent: true,
},
{
source: '/dashboard',
destination: '/daiwallet/dashboard',
permanent: true,
},
{
source: '/(0x[a-fA-F0-9]{40}.*)',
destination: '/daiwallet/dashboard',
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-Origin', value: 'https://gnosis-safe.io' },
],
},
]
},
}),
),
)
// sentry needs to be last for accurate sourcemaps
module.exports = withSentryConfig(conf, {
org: 'block360-0e',
project: 'gsu-demo',
url: 'https://sentry.io/',
silent:true
})