-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
88 lines (80 loc) · 3.17 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
/** @type {import('next').NextConfig} */
const fs = require("fs");
const { withSentryConfig } = require("@sentry/nextjs");
const download = require("download");
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
org: "sre",
project: "pki-frontend",
url: "https://sentry.hm.edu/",
reactComponentAnnotation: {
enabled: true,
},
hideSourceMaps: true,
widenClientFileUpload: true,
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
module.exports = (phase, { defaultConfig }) => {
let moduleExports = {
poweredByHeader: false,
reactStrictMode: true,
productionBrowserSourceMaps: true,
output: process.env.NEXT_PUBLIC_CI == "true" ? undefined : "standalone",
compiler: {
emotion: true,
},
modularizeImports: {
"@mui/icons-material": {
transform: "@mui/icons-material/{{member}}",
},
},
webpack: (config, { webpack, isServer }) => {
(async () => {
if (process.env.LOGO_LARGE) {
fs.writeFileSync("./public/logo.png", await download(process.env.LOGO_LARGE));
}
if (process.env.LOGO_SMALL) {
fs.writeFileSync("./public/logo-small.png", await download(process.env.LOGO_SMALL));
}
if (process.env.FAVICON) {
fs.writeFileSync("./public/favicon.ico", await download(process.env.FAVICON));
}
})();
const envs = {};
Object.keys(process.env).forEach((env) => {
if (env.startsWith("NEXT_PUBLIC_") && env != "NEXT_PUBLIC_SENTRY_DSN") {
envs[env] = process.env[env];
}
});
for (const env in envs) {
envs[env.replace("NEXT_PUBLIC_", "")] = envs[env];
}
if (!isServer) {
console.log("Providing following environment variables during runtime: \n", envs);
config.plugins.push(
new webpack.DefinePlugin({
"process.env": JSON.stringify(envs),
}),
);
}
config.ignoreWarnings = [
{ module: /@opentelemetry\/instrumentation/, message: /Critical dependency/ },
{ module: /@prisma\/instrumentation/, message: /Critical dependency/ },
];
return defaultConfig.webpack ? defaultConfig.webpack(config) : config;
},
};
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
console.log("Sentry DSN found, enabling Sentry monitoring");
moduleExports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);
} else {
moduleExports = moduleExports;
}
return moduleExports;
};