-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnext.config.js
More file actions
153 lines (138 loc) · 3.96 KB
/
next.config.js
File metadata and controls
153 lines (138 loc) · 3.96 KB
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
const path = require('path')
const webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin')
const CircularDependencyPlugin = require('circular-dependency-plugin')
const mainRPC = process.env.NEXT_PUBLIC_MAINNET_NETWORK_URL
const fallbackRPC = process.env.NEXT_PUBLIC_MAINNET_FALLBACK_URL
const isProduction = process.env.NEXT_PUBLIC_IS_PROD !== 'false'
console.log('-------------------------------information---------------------------------')
console.log('Main RPC:', mainRPC)
console.log('Fallback RPC:', fallbackRPC)
console.log('This is production build:', isProduction ? 'YES' : 'NO')
console.log('---------------------------------------------------------------------------')
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
reactStrictMode: false,
sassOptions: {
additionalData: `
@use 'src/styles/variables' as *;
@use 'src/styles/mixins/media' as *;
@use 'src/styles/mixins/common' as *;
@use 'src/styles/mixins/animation' as *;
`,
includePaths: [
path.join(__dirname, 'src', 'styles'),
],
},
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: "Access-Control-Allow-Origin",
value: '*',
},
{
key: "Access-Control-Allow-Methods",
value: 'GET',
},
{
key: "Access-Control-Allow-Headers",
value: 'X-Requested-With, content-type, Authorization',
},
{
key: "Content-Security-Policy",
// https://ethereum.stackexchange.com/questions/145491/getting-the-app-doesnt-support-safe-app-functionality
value: `frame-ancestors 'self' ${process.env.NEXT_PUBLIC_CONTENT_SECURITY_POLICY};`,
},
],
},
]
},
webpack: (config) => {
config.resolve = {
...config.resolve,
fallback: {
...config.resolve.fallback,
net: false,
tls: false,
},
}
config.externals.push(
'pino-pretty'
)
config.plugins.push(
new webpack.DefinePlugin({
'IS_PROD': isProduction,
// Technical variable
'IS_LIGHTWEIGHT_MODE': false,
// Creates a unique identifier where this variable is used in code
'UNIQUE_FILE_ID': webpack.DefinePlugin.runtimeValue(
(compiler) => {
const filePath = compiler.module.resource
return JSON.stringify(filePath)
}, []
),
}),
new webpack.NormalModuleReplacementPlugin(/(.*\.graphql)$/m, (resource) => {
resource.request = resource.request.replace(/(.*\.graphql)$/m, '$1.ts')
})
)
const prefix = config.assetPrefix || ''
const basePath = config.basePath || ''
config.module.rules.push({
test: /\.(mp4|webm|mov|ogg|swf|ogv)$/,
use: [
{
loader: require.resolve('file-loader'),
options: {
publicPath: `${prefix || basePath}/_next/static/videos/`,
outputPath: `static/videos/`,
name: '[name]-[hash].[ext]',
},
},
],
})
if (!isProduction) {
config.plugins.push(
new CircularDependencyPlugin({
include: /src/,
failOnError: true,
cwd: process.cwd(),
allowAsyncCycles: false,
exclude: /a\.js|node_modules/,
})
)
return config
}
config.optimization = {
...config.optimization,
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: true,
mangle: true,
},
}),
],
}
return config
},
}
module.exports = nextConfig