-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
56 lines (51 loc) · 1.74 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
// This is a cjs file
/* eslint-disable @typescript-eslint/no-var-requires */
const { i18n } = require('./next-i18next.config');
const { BugsnagSourceMapUploaderPlugin, BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins');
/** @type {import('next').NextConfig} */
module.exports = {
i18n,
productionBrowserSourceMaps: true,
reactStrictMode: true,
output: 'standalone',
webpack(config, { buildId, isServer, webpack }) {
config.plugins.push(
new webpack.DefinePlugin({
// Define the build id so that it can be accessed in the client when reporting errors
'process.env.NEXT_BUILD_ID': JSON.stringify(buildId),
'process.env.NEXT_IS_SERVER': JSON.stringify(isServer),
})
);
// Avoid including '@bugsnag/plugin-aws-lambda' module in the client side bundle
// See https://arunoda.me/blog/ssr-and-server-only-modules
if (!isServer) {
config.plugins.push(new webpack.IgnorePlugin({ resourceRegExp: /@bugsnag\/plugin-aws-lambda/ }));
}
// Upload source maps on production build
if (
process.env.NEXT_PUBLIC_BUGSNAG_API_KEY &&
process.env.NODE_ENV === 'production' &&
process.env.NEXT_PUBLIC_NEXT_APP_ENV !== 'development' &&
process.env.SITE_URL
) {
config.plugins.push(
new BugsnagBuildReporterPlugin(
{
apiKey: process.env.NEXT_PUBLIC_BUGSNAG_API_KEY,
appVersion: buildId,
releaseStage: process.env.NEXT_PUBLIC_NEXT_APP_ENV,
},
{ logLevel: 'debug' }
),
new BugsnagSourceMapUploaderPlugin({
apiKey: process.env.NEXT_PUBLIC_BUGSNAG_API_KEY,
appVersion: buildId,
publicPath: isServer ? '.next/server/' : `${process.env.SITE_URL}/_next/`,
releaseStage: process.env.NEXT_PUBLIC_NEXT_APP_ENV,
overwrite: true,
})
);
}
return config;
},
};