forked from ensdomains/ens-app-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
141 lines (135 loc) · 3.63 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
// @ts-check
const { i18n } = require('./next-i18next.config')
const { withPlugins } = require('next-compose-plugins')
const path = require('path')
const StylelintPlugin = require('stylelint-webpack-plugin')
const { withSentryConfig } = require('@sentry/nextjs')
const { execSync } = require('child_process')
/**
* @type {import('next').NextConfig}
**/
let nextConfig = {
reactStrictMode: true,
compiler: {
styledComponents: true,
},
experimental: {
// remove this once this PR is merged to main: https://github.com/vercel/next.js/pull/33236
swcFileReading: false,
},
// change to true once infinite loop is fixed
swcMinify: false,
// @ts-ignore
images: {
domains: ['metadata.ens.domains'],
},
async rewrites() {
return [
{
source: '/my/profile',
destination: '/profile?connected=true',
},
{
source: '/names/:address',
destination: '/my/names?address=:address',
},
{
source: '/profile/:name',
destination: '/profile?name=:name',
},
{
source: '/register/:name',
destination: '/register?name=:name',
},
{
source: '/import/:name',
destination: '/import?name=:name',
},
{
source: '/address/:address',
destination: '/address?address=:address',
},
]
},
generateBuildId: () => {
const hash = execSync('git rev-parse HEAD').toString().trim()
return hash
},
webpack: (config, options) => {
config.module.rules.push({
test: /ens.+\.json$/,
use: {
loader: path.resolve(__dirname, './loaders/abi-loader.js'),
options: {},
},
})
config.module.rules.push({
test: /\.svg$/,
issuer: /\.tsx?$/,
include: [options.dir],
use: [
'next-swc-loader',
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: [
{
name: 'removeViewBox',
active: false,
},
],
},
babel: false,
},
},
],
})
config.plugins.push(
new StylelintPlugin({
files: './src/**/*.tsx',
extensions: ['tsx'],
failOnError: process.env.NODE_ENV !== 'development',
cache: false,
}),
)
config.plugins.push(
new options.webpack.DefinePlugin({
'process.env.CONFIG_BUILD_ID': JSON.stringify(options.buildId),
}),
)
if (process.env.NEXT_PUBLIC_IPFS) {
config.resolve.alias['../styles.css'] = path.resolve(__dirname, 'src/stub.css')
}
return config
},
...(process.env.NEXT_PUBLIC_IPFS
? {
trailingSlash: true,
assetPrefix: './',
}
: {}),
}
let plugins = []
if (process.env.ANALYZE) {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: true,
})
plugins.push([withBundleAnalyzer])
}
const withSentry = (config) => {
const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
if (process.env.NODE_ENV === 'production' && !process.env.NEXT_PUBLIC_IPFS)
return withSentryConfig(config, sentryWebpackPluginOptions)
return config
}
module.exports = withSentry(withPlugins(plugins, nextConfig))