Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
266 lines (255 loc) · 8.1 KB
/
Copy pathnext.config.js
File metadata and controls
266 lines (255 loc) · 8.1 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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
require("@akashnetwork/env-loader");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true"
});
const { version, repository } = require("./package.json");
const { withSentryConfig } = require("@sentry/nextjs");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const { sdlSchemaSourcePath } = require("./scripts/copy-sdl-schema");
const transpilePackages = ["geist", "@akashnetwork/ui", "@auth0/nextjs-auth0"];
/** Aliases to auth0 internals patched by ./src/lib/auth0/setSession/setSession.ts, shared by the webpack and turbopack configs. */
const auth0SessionAliases = {
"@auth0/nextjs-auth0/session": path.join(require.resolve("@auth0/nextjs-auth0"), "..", "session", "index.js"),
"@auth0/nextjs-auth0/update-session": path.join(require.resolve("@auth0/nextjs-auth0"), "..", "session", "update-session.js")
};
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
reactStrictMode: false,
productionBrowserSourceMaps: true,
env: {
NEXT_PUBLIC_APP_VERSION: version,
NEXT_PUBLIC_SENTRY_ENVIRONMENT: process.env.SENTRY_ENVIRONMENT || process.env.DEPLOYMENT_ENV
},
compiler: {
// Enables the styled-components SWC transform
styledComponents: true
},
images: {
localPatterns: [{ pathname: "/images/**", search: "" }],
qualities: [75]
},
output: "standalone",
typescript: {
tsconfigPath: "./tsconfig.build.json"
},
eslint: {
ignoreDuringBuilds: true
},
transpilePackages,
/**
* Only the local raw-TS barrels: barrel-optimizing CJS packages (e.g. @nivo/*)
* rewrites imports to their dist files and breaks the webpack prod build on
* ESM externals. MUI, lucide-react etc. are already in Next's default list.
*/
experimental: {
optimizePackageImports: ["@akashnetwork/ui/components", "@akashnetwork/ui/hooks", "@akashnetwork/ui/context", "@akashnetwork/ui/utils"]
},
/**
* Dev-only (next dev --turbopack). Mirrors the webpack customizations below,
* which Turbopack ignores; prod builds still go through the webpack fn.
* The prettier stubs are intentionally not mirrored: they only trim the prod
* bundle, and Turbopack rejects empty stubs for named imports.
*/
turbopack: {
resolveAlias: {
"pino-pretty": { browser: "./src/stubs/empty.ts" },
...Object.fromEntries(Object.entries(auth0SessionAliases).map(([specifier, filePath]) => [specifier, path.relative(__dirname, filePath)]))
}
},
i18n: {
locales: ["en-US"],
defaultLocale: "en-US"
},
/**
*
* @param {import('webpack').Configuration} config
* @param {import('next').NextConfig} nextConfig
* @returns
*/
webpack: (config, options) => {
// Fixes npm packages that depend on `node:crypto` module
config.externals.push({
"node:crypto": "crypto"
});
config.externals.push("pino-pretty");
config.resolve.alias = {
...config.resolve.alias,
// Stub prettier to reduce bundle size (used by monaco-yaml for formatting, which we disable)
"prettier/standalone": false,
"prettier/plugins/yaml": false,
prettier: false
};
if (options.isServer) {
Object.assign(config.resolve.alias, auth0SessionAliases);
} else {
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: sdlSchemaSourcePath,
to: "../public/sdl-schema.yaml"
}
]
})
);
}
if (process.env.ANALYZE === "true") {
// More readable in bundle analyzer
config.optimization.moduleIds = "named";
config.optimization.chunkIds = "named";
}
return config;
},
redirects: async () => {
return [
{
source: "/",
destination: "/deployments",
permanent: false
},
{
source: "/sdl-builder",
has: [{ type: "query", key: "id", value: "(?<userTemplateId>.+)" }],
destination: "/new-deployment/configure?userTemplateId=:userTemplateId",
permanent: true
},
{
source: "/sdl-builder",
destination: "/new-deployment/configure",
permanent: true
},
{
source: "/deploy-linux",
destination: "/new-deployment/configure?vm=true",
permanent: true
},
{
source: "/deploy",
destination: "/cloud-deploy",
permanent: true
},
{
source: "/alerts/:path+",
destination: "/alerts",
permanent: false
},
{
source: "/providers/:owner/:tab(leases|raw)",
destination: "/providers/:owner",
permanent: false
},
{
source: "/price-compare",
destination: "https://akash.network/about/pricing/custom/",
permanent: false
},
{
source: "/analytics",
destination: "https://stats.akash.network",
permanent: false
},
{
source: "/graph/active-deployment",
destination: "https://stats.akash.network/graph/active-leases",
permanent: false
},
{
source: "/graph/:path*",
destination: "https://stats.akash.network/graph/:path*",
permanent: false
},
{
source: "/validators",
destination: "https://stats.akash.network/validators",
permanent: false
},
{
source: "/validators/:address*",
destination: "https://stats.akash.network/validators/:address*",
permanent: false
},
{
source: "/addresses/:address*",
destination: "https://stats.akash.network/addresses/:address*",
permanent: false
},
{
source: "/addresses/:address/transactions",
destination: "https://stats.akash.network/addresses/:address/transactions",
permanent: false
},
{
source: "/addresses/:address/deployments",
destination: "https://stats.akash.network/addresses/:address/deployments",
permanent: false
},
{
source: "/deployment/:address/:dseq*",
destination: "https://stats.akash.network/addresses/:address/deployments/:dseq*",
permanent: false
},
{
source: "/blocks",
destination: "https://stats.akash.network/blocks",
permanent: false
},
{
source: "/blocks/:height*",
destination: "https://stats.akash.network/blocks/:height*",
permanent: false
},
{
source: "/transactions",
destination: "https://stats.akash.network/transactions",
permanent: false
},
{
source: "/transactions/:hash*",
destination: "https://stats.akash.network/transactions/:hash*",
permanent: false
}
];
}
};
const REPOSITORY_URL = new URL(repository.url);
/**
* For all available options, see:
* https://github.com/getsentry/sentry-webpack-plugin#options.
* @type {import('@sentry/nextjs').SentryBuildOptions}
*/
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: !process.env.CI, // Suppresses all logs,
// dryRun: true,
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
release: {
name: version,
setCommits: {
repo: REPOSITORY_URL.pathname.slice(1).replace(/\.git$/, ""),
commit: process.env.GIT_COMMIT_HASH
}
},
sourcemaps: {
deleteSourcemapsAfterUpload: false
},
widenClientFileUpload: true,
debug: !process.env.CI,
reactComponentAnnotation: {
enabled: true
},
unstable_sentryWebpackPluginOptions: {
applicationKey: process.env.NEXT_PUBLIC_SENTRY_APPLICATION_KEY
}
};
// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withBundleAnalyzer(sentryWebpackPluginOptions.authToken ? withSentryConfig(nextConfig, sentryWebpackPluginOptions) : nextConfig);