-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnext.config.js
135 lines (125 loc) · 4.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
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
const withPlugins = require("next-compose-plugins");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const { i18n } = require("./next-i18next.config");
// Use the SentryWebpack plugin to upload the source maps during build step
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const {
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
SENTRY_ORG,
SENTRY_PROJECT,
SENTRY_AUTH_TOKEN,
NODE_ENV,
VERCEL_GIT_COMMIT_SHA,
VERCEL_GITHUB_COMMIT_SHA,
VERCEL_GITLAB_COMMIT_SHA,
VERCEL_BITBUCKET_COMMIT_SHA,
SOURCE_VERSION,
} = process.env;
const COMMIT_SHA =
VERCEL_GIT_COMMIT_SHA ||
VERCEL_GITHUB_COMMIT_SHA ||
VERCEL_GITLAB_COMMIT_SHA ||
VERCEL_BITBUCKET_COMMIT_SHA ||
SOURCE_VERSION;
process.env.SENTRY_DSN = SENTRY_DSN;
const basePath = "";
const scheme =
process.env.SCHEME === "http" || process.env.SCHEME === "https"
? process.env.SCHEME
: "https";
let APPUrl;
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
APPUrl = `${scheme}://${process.env.VERCEL_URL}`;
} else {
APPUrl = process.env.APP_URL;
}
const hasAssetPrefix =
process.env.ASSET_PREFIX !== "" && process.env.ASSET_PREFIX !== undefined;
module.exports = withPlugins([[withBundleAnalyzer]], {
productionBrowserSourceMaps: true,
serverRuntimeConfig: {
rootDir: __dirname,
},
webpack: (config, options) => {
// In `pages/_app.js`, Sentry is imported from @sentry/browser. While
// @sentry/node will run in a Node.js environment. @sentry/node will use
// Node.js-only APIs to catch even more unhandled exceptions.
//
// This works well when Next.js is SSRing your page on a server with
// Node.js, but it is not what we want when your client-side bundle is being
// executed by a browser.
//
// Luckily, Next.js will call this webpack function twice, once for the
// server and once for the client. Read more:
// https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
//
// So ask Webpack to replace @sentry/node imports with @sentry/browser when
// building the browser's bundle
if (!options.isServer) {
config.resolve.alias["@sentry/node"] = "@sentry/browser";
}
// config.node = {
// fs: 'empty',
// };
// When all the Sentry configuration env variables are available/configured
// The Sentry webpack plugin gets pushed to the webpack plugins to build
// and upload the source maps to sentry.
// This is an alternative to manually uploading the source maps
// Note: This is disabled in development mode.
if (
SENTRY_DSN &&
SENTRY_ORG &&
SENTRY_PROJECT &&
SENTRY_AUTH_TOKEN &&
COMMIT_SHA &&
NODE_ENV === "production"
) {
config.plugins.push(
new SentryWebpackPlugin({
include: ".next",
ignore: ["node_modules"],
stripPrefix: ["webpack://_N_E/"],
urlPrefix: `~${basePath}/_next`,
release: COMMIT_SHA,
})
);
}
return config;
},
basePath,
// your config for other plugins or the general next.js here...
devIndicators: {
autoPrerender: false,
},
env: {
AUTH0_CUSTOM_DOMAIN: process.env.AUTH0_CUSTOM_DOMAIN,
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
SCHEME: scheme,
API_ENDPOINT: `${scheme}://${process.env.API_ENDPOINT}`,
CDN_URL: `${scheme}://${process.env.CDN_URL}`,
APP_URL: APPUrl,
VERCEL_URL: process.env.VERCEL_URL,
ESRI_CLIENT_ID: process.env.ESRI_CLIENT_ID,
ESRI_CLIENT_SECRET: process.env.ESRI_CLIENT_SECRET,
RECURRENCY: process.env.RECURRENCY,
},
trailingSlash: false,
reactStrictMode: true,
poweredByHeader: false,
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
assetPrefix: hasAssetPrefix ? `${scheme}://${process.env.ASSET_PREFIX}` : "",
// Asset Prefix allows to use CDN for the generated js files
// https://nextjs.org/docs/api-reference/next.config.js/cdn-support-with-asset-prefix
i18n,
images: {
domains: ["cdn.plant-for-the-planet.org", "cdn.planetapp.workers.dev"],
},
});