forked from saleor/dummy-payment-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
62 lines (55 loc) · 1.67 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
// @ts-check
import withBundleAnalyzerConfig from "@next/bundle-analyzer";
import { withSentryConfig } from "@sentry/nextjs";
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
optimizePackageImports: [
"@sentry/nextjs",
"@sentry/node",
"usehooks-ts",
"@saleor/app-sdk",
"@trpc/server",
"@trpc/client",
"@trpc/react-query",
"@trpc/next",
"jotai",
"@saleor/apps-shared",
],
},
/*
* Ignore opentelemetry warnings - https://github.com/open-telemetry/opentelemetry-js/issues/4173
* Remove when https://github.com/open-telemetry/opentelemetry-js/pull/4660 is released
*/
/** @type {import('next').NextConfig['webpack']} */
webpack: (config, { isServer }) => {
if (isServer) {
config.ignoreWarnings = [{ module: /opentelemetry/ }];
}
return config;
},
};
const configWithSentry = withSentryConfig(
nextConfig,
{
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
silent: true,
},
{
hideSourceMaps: true,
widenClientFileUpload: true,
disableLogger: true,
transpileClientSDK: true,
tunnelRoute: "/monitoring",
},
);
const withBundleAnalyzer = withBundleAnalyzerConfig({
enabled: process.env.ANALYZE_BUNDLE === "true",
});
const isSentryPropertiesInEnvironment =
process.env.SENTRY_AUTH_TOKEN && process.env.SENTRY_PROJECT && process.env.SENTRY_ORG;
const config = isSentryPropertiesInEnvironment ? configWithSentry : nextConfig;
// @ts-expect-error bundle analyzer requires NextConfig when Sentry is returning NextConfigFunction | NextConfigObject
export default withBundleAnalyzer(config);