-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathnext.config.js
More file actions
122 lines (107 loc) · 5.13 KB
/
Copy pathnext.config.js
File metadata and controls
122 lines (107 loc) · 5.13 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
const path = require("path");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.BUNDLE_ANALYZE === "true",
});
/** @type {import('next').NextConfig} */
const nextConfig = {
trailingSlash: true,
output: "export",
transpilePackages: [
"react-pdf",
"pdfjs-dist",
"@trustvc/trustvc",
"@trustvc/w3c-vc",
"@trustvc/w3c-issuer",
"@trustvc/w3c-context",
"@trustvc/w3c-credential-status",
],
exportPathMap: function exportMap() {
return {
"/": { page: "/" },
"/privacy": { page: "/privacy" },
"/terms": { page: "/terms" },
"/viewer": { page: "/viewer" },
"/faq": { page: "/faq" },
"/collaborator": { page: "/collaborator" },
};
},
env: {
INFURA_API_KEY_PROVIDER: process.env.INFURA_API_KEY_PROVIDER, // Used by the verification provider
INFURA_API_KEY_RESOLVER: process.env.INFURA_API_KEY_RESOLVER, // Used by the mainnet did:ethr resolver
ALCHEMY_API_KEY: process.env.ALCHEMY_API_KEY, // The default/free key should not be used in production as they are rate-limited by the service provider
TRUSTED_TLDS: process.env.TRUSTED_TLDS || "gov.sg,edu.sg",
GA4_TAG_ID: process.env.GA4_TAG_ID,
GTM_CONTAINER_ID: process.env.GTM_CONTAINER_ID,
// Static export: these must be NEXT_PUBLIC_* at build time (set in deploy workflows).
NEXT_PUBLIC_SENTRY_ENVIRONMENT: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT || process.env.SENTRY_ENVIRONMENT || "",
NEXT_PUBLIC_SENTRY_RELEASE: process.env.NEXT_PUBLIC_SENTRY_RELEASE || process.env.SENTRY_RELEASE || "",
},
// Variables passed to both server and client
publicRuntimeConfig: {
network: process.env.NET,
legacyRendererUrl: process.env.LEGACY_RENDERER_URL,
context: process.env.CONTEXT, // https://www.netlify.com/docs/continuous-deployment/?_ga=2.254249672.1986722564.1569467860-817711885.1562657089#build-environment-variables
},
experimental: {
// workaround to for next to play nice with oa-verify's new version
// might be related to https://github.com/vercel/next.js/issues/39375#issuecomment-1380266233
esmExternals: false,
},
webpack: (config) => {
// @trustvc/trustvc imports dotenv/config at the top level in its ESM build,
// which is Node.js-only and cannot be resolved in a browser bundle.
config.resolve.alias["dotenv/config"] = false;
// @mattrglobal/bbs-signatures conditionally requires this native addon only in Node.js.
// In the browser it uses WASM instead, so we stub it out to prevent webpack from failing.
config.resolve.alias["@mattrglobal/node-bbs-signatures"] = false;
// @digitalbazaar/bbs-signatures uses `node:crypto` for webcrypto.
// In the browser, the Web Crypto API is available as globalThis.crypto.
// We provide a browser shim that re-exports webcrypto from the global.
config.resolve.alias["@digitalbazaar/bbs-signatures/lib/crypto.js"] = path.resolve("./src/shims/bbs-crypto.js");
// Force all packages to use the same React instance to prevent hook errors
// when using local packages that have their own node_modules/react.
config.resolve.alias["react"] = path.resolve("./node_modules/react");
config.resolve.alias["react-dom"] = path.resolve("./node_modules/react-dom");
return config;
},
};
module.exports = withBundleAnalyzer(nextConfig);
// Injected content via Sentry wizard below
const { withSentryConfig } = require("@sentry/nextjs");
const hasSentryAuthToken = Boolean(String(process.env.SENTRY_AUTH_TOKEN || "").trim());
const uploadExplicitlyDisabled = process.env.SENTRY_UPLOAD_SOURCE_MAPS === "false";
const uploadExplicitlyEnabled = process.env.SENTRY_UPLOAD_SOURCE_MAPS === "true";
const skipSentryBuildUploadOnGithubActions = process.env.GITHUB_ACTIONS === "true" && !uploadExplicitlyEnabled;
const skipSentryBuildUpload = uploadExplicitlyDisabled || !hasSentryAuthToken || skipSentryBuildUploadOnGithubActions;
module.exports = withSentryConfig(module.exports, {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
org: "opencerts",
project: "opencerts-website",
...(skipSentryBuildUpload
? {
sourcemaps: { disable: true },
release: { create: false, finalize: false },
}
: {}),
telemetry: false,
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
// tunnelRoute: "/monitoring",
webpack: {
automaticVercelMonitors: false,
// Tree-shaking options for reducing bundle size
treeshake: {
// Automatically tree-shake Sentry logger statements to reduce bundle size
removeDebugLogging: true,
},
},
});