ente/next.config.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

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');
const WorkerPlugin = require('worker-plugin');
2020-10-03 14:21:56 +00:00
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
2021-06-07 05:34:41 +00:00
const withWorkbox = require('next-with-workbox');
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 = '';
2021-05-23 14:25:48 +00:00
module.exports = withWorkbox(withBundleAnalyzer({
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,
},
2021-05-23 14:25:48 +00:00
workbox: {
2021-06-07 05:34:41 +00:00
swSrc: 'src/serviceWorker.js',
2021-06-15 05:02:46 +00:00
exclude: [/manifest.json$/i],
2021-05-23 14:25:48 +00:00
},
2021-05-29 06:27:52 +00:00
webpack: (config, { isServer, 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',
2021-06-07 05:34:41 +00:00
}),
2021-03-08 11:59:14 +00:00
);
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(
2021-06-07 05:34:41 +00:00
isServer.toString(),
2021-03-08 11:59:14 +00:00
),
2021-06-07 05:34:41 +00:00
}),
2021-03-08 11:59:14 +00:00
);
if (
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`,
2021-06-07 05:34:41 +00:00
}),
2021-03-08 11:59:14 +00:00
);
}
2021-03-08 11:59:14 +00:00
return config;
},
2021-05-23 14:25:48 +00:00
}));