forked from superfluid-org/superfluid-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
91 lines (82 loc) · 3.37 KB
/
next.config.js
File metadata and controls
91 lines (82 loc) · 3.37 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
// This file sets a custom webpack configuration to use your Next.js app
// with Sentry.
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
const { withSentryConfig } = require("@sentry/nextjs");
const sentryEnvironment =
process.env.SENTRY_ENVIRONMENT || process.env.CONTEXT;
const netlifyContext = process.env.CONTEXT;
const isOnNetlify = !!netlifyContext;
const interfaceFeeAddress = process.env.INTERFACE_FEE_ADDRESS;
const shouldInstrumentCode = "INSTRUMENT_CODE" in process.env;
const appUrl = process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : process.env.URL;
function withSentryIfNecessary(nextConfig) {
console.log({
sentryEnvironment,
netlifyContext,
isOnNetlify,
interfaceFeeAddress,
shouldInstrumentCode,
appUrl
});
const SENTRY_AUTH_TOKEN = process.env.SENTRY_AUTH_TOKEN;
if (!SENTRY_AUTH_TOKEN) {
console.warn(
"Sentry release not created because SENTRY_AUTH_TOKEN is not set."
);
return nextConfig;
}
// 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
// NOTE from developer: withTM is also recommended to keep last.
return withSentryConfig(nextConfig, {
// 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
env: sentryEnvironment,
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
hideSourceMaps: true, // If this not specified as `true` then Sentry will expose the production source maps. We've decided to expose the source maps though.
});
}
/** @type {import('next').NextConfig} */
const moduleExports = {
reactStrictMode: true,
images: {
loader: "custom",
remotePatterns: [
{
protocol: "https",
hostname: "raw.githubusercontent.com",
port: "",
pathname: "/superfluid-finance/**/*",
},
{
protocol: "https",
hostname: "superfluid-finance.github.io",
port: "",
pathname: "/**/*",
},
],
},
env: {
NEXT_PUBLIC_APP_URL: appUrl,
NEXT_PUBLIC_SENTRY_ENVIRONMENT: sentryEnvironment,
NEXT_PUBLIC_NETLIFY_CONTEXT: process.env.CONTEXT, // https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
},
productionBrowserSourceMaps: false, // NOTE: If this is set to `false` then be careful -- Sentry might still override this to `true`...
// Modularize imports to prevent compilation of unused modules.
// More info here: https://nextjs.org/docs/advanced-features/compiler
// modularizeImports: // It's enabled automatically for many packages in use: https://nextjs.org/docs/app/api-reference/next-config-js/optimizePackageImports
experimental: {
forceSwcTransforms: !shouldInstrumentCode, // .babelrc.js existence is because of code instrumentation.
cpus: isOnNetlify ? 6 : undefined // Fixes the issue of memory running out on Netlify (error 127)
},
eslint: {
ignoreDuringBuilds: isOnNetlify,
}
};
module.exports = withSentryIfNecessary(moduleExports);