ente/packages/shared/next/next.config.base.js

62 lines
2.1 KiB
JavaScript
Raw Normal View History

2023-11-09 04:10:43 +00:00
const { withSentryConfig } = require('@sentry/nextjs');
2024-02-10 17:29:04 +00:00
const cp = require('child_process');
const gitSHA = cp.execSync('git rev-parse --short HEAD', {
cwd: __dirname,
encoding: 'utf8',
});
2023-11-09 04:10:43 +00:00
2024-02-10 14:14:12 +00:00
const nextConfig = {
compiler: {
emotion: {
importMap: {
'@mui/material': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: ['@mui/material', 'styled'],
},
},
'@mui/material/styles': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: ['@mui/material/styles', 'styled'],
2023-11-09 04:10:43 +00:00
},
},
2023-11-09 04:24:54 +00:00
},
2023-11-09 04:10:43 +00:00
},
2024-02-10 14:14:12 +00:00
},
transpilePackages: ['@mui/material', '@mui/system', '@mui/icons-material'],
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
2023-11-09 04:10:43 +00:00
}
2024-02-10 14:14:12 +00:00
return config;
},
// Build time Sentry configuration
sentry: {
widenClientFileUpload: true,
2024-02-10 16:03:24 +00:00
disableServerWebpackPlugin: true,
2024-02-10 14:14:12 +00:00
},
};
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
2024-02-10 17:29:04 +00:00
const sentryWebpackPluginOptions = {
// Sentry supports automatically deducing this, and if running the
// sentry-cli release propose-version command directly, it can indeed find
// the git SHA, but I've been unable to get that to work here without
// explicitly specifying the git SHA.
release: gitSHA,
2024-02-10 14:14:12 +00:00
};
// withSentryConfig extends the default Next.js usage of webpack to
// 1. Initialize the SDK on client page load (`sentry.client.config.ts`)
2024-02-10 17:29:04 +00:00
// 2. Upload sourcemaps (using the settings defined in `sentry.properties`)
//
// Irritatingly, it insists that we also provide it (empty)
// sentry.server.config.ts and sentry.edge.config.ts files too, even though we
// are not using those parts.
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);