2021-03-08 11:59:14 +00:00
|
|
|
// Use the SentryWebpack plugin to upload the source maps during build step
|
|
|
|
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
|
2020-09-19 21:20:10 +00:00
|
|
|
const WorkerPlugin = require('worker-plugin');
|
2020-10-03 14:21:56 +00:00
|
|
|
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
|
|
|
enabled: process.env.ANALYZE === 'true',
|
|
|
|
});
|
2020-09-19 21:20:10 +00:00
|
|
|
|
2021-03-08 11:59:14 +00:00
|
|
|
const {
|
|
|
|
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
|
|
|
|
SENTRY_ORG,
|
|
|
|
SENTRY_PROJECT,
|
|
|
|
SENTRY_AUTH_TOKEN,
|
|
|
|
NODE_ENV,
|
2021-03-12 05:46:08 +00:00
|
|
|
GITHUB_COMMIT_SHA: COMMIT_SHA,
|
2021-03-08 11:59:14 +00:00
|
|
|
} = process.env;
|
|
|
|
|
|
|
|
process.env.SENTRY_DSN = SENTRY_DSN;
|
|
|
|
const basePath = '';
|
|
|
|
|
2020-10-03 14:21:56 +00:00
|
|
|
module.exports = withBundleAnalyzer({
|
2020-09-19 21:20:10 +00:00
|
|
|
target: 'serverless',
|
2021-03-08 11:59:14 +00:00
|
|
|
productionBrowserSourceMaps: true,
|
|
|
|
env: {
|
|
|
|
// Make the COMMIT_SHA available to the client so that Sentry events can be
|
|
|
|
// marked for the release they belong to. It may be undefined if running
|
|
|
|
// outside of Vercel
|
|
|
|
NEXT_PUBLIC_COMMIT_SHA: COMMIT_SHA,
|
|
|
|
},
|
2020-09-19 21:20:10 +00:00
|
|
|
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
|
|
|
if (!isServer) {
|
2021-03-08 11:59:14 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new WorkerPlugin({
|
|
|
|
// use "self" as the global object when receiving hot updates.
|
|
|
|
globalObject: 'self',
|
|
|
|
})
|
|
|
|
);
|
|
|
|
config.resolve.alias['@sentry/node'] = '@sentry/browser';
|
|
|
|
}
|
|
|
|
// Define an environment variable so source code can check whether or not
|
|
|
|
// it's running on the server so we can correctly initialize Sentry
|
|
|
|
config.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NEXT_IS_SERVER': JSON.stringify(
|
|
|
|
isServer.toString()
|
|
|
|
),
|
2020-09-19 21:20:10 +00:00
|
|
|
})
|
2021-03-08 11:59:14 +00:00
|
|
|
);
|
|
|
|
if (
|
2021-03-12 08:22:29 +00:00
|
|
|
false &&
|
2021-03-08 11:59:14 +00:00
|
|
|
SENTRY_DSN &&
|
|
|
|
SENTRY_ORG &&
|
|
|
|
SENTRY_PROJECT &&
|
|
|
|
SENTRY_AUTH_TOKEN &&
|
|
|
|
NODE_ENV === 'production'
|
|
|
|
) {
|
|
|
|
config.plugins.push(
|
|
|
|
new SentryWebpackPlugin({
|
|
|
|
include: '.next',
|
|
|
|
ignore: ['node_modules'],
|
|
|
|
stripPrefix: ['webpack://_N_E/'],
|
|
|
|
urlPrefix: `~${basePath}/_next`,
|
|
|
|
})
|
|
|
|
);
|
2020-09-19 21:20:10 +00:00
|
|
|
}
|
2021-03-08 11:59:14 +00:00
|
|
|
return config;
|
2020-09-19 21:20:10 +00:00
|
|
|
},
|
2020-10-03 14:21:56 +00:00
|
|
|
});
|