next.config.base.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @file Configure the Next.js build
  3. *
  4. * This file gets used by the Next.js build phase, and is not included in the
  5. * browser build. It will not be parsed by Webpack, Babel or TypeScript, so
  6. * don't use features that will not be available in our target node version.
  7. *
  8. * https://nextjs.org/docs/pages/api-reference/next-config-js
  9. */
  10. const { withSentryConfig } = require('@sentry/nextjs');
  11. const cp = require('child_process');
  12. const gitSHA = cp.execSync('git rev-parse --short HEAD', {
  13. cwd: __dirname,
  14. encoding: 'utf8',
  15. });
  16. const nextConfig = {
  17. compiler: {
  18. emotion: {
  19. importMap: {
  20. '@mui/material': {
  21. styled: {
  22. canonicalImport: ['@emotion/styled', 'default'],
  23. styledBaseImport: ['@mui/material', 'styled'],
  24. },
  25. },
  26. '@mui/material/styles': {
  27. styled: {
  28. canonicalImport: ['@emotion/styled', 'default'],
  29. styledBaseImport: ['@mui/material/styles', 'styled'],
  30. },
  31. },
  32. },
  33. },
  34. },
  35. transpilePackages: ['@mui/material', '@mui/system', '@mui/icons-material'],
  36. // Add environment variables to the JavaScript bundle. They will be
  37. // available as `process.env.VAR_NAME` to our code.
  38. env: {
  39. GIT_SHA: gitSHA,
  40. },
  41. // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
  42. webpack: (config, { isServer }) => {
  43. if (!isServer) {
  44. config.resolve.fallback.fs = false;
  45. }
  46. return config;
  47. },
  48. // Build time Sentry configuration
  49. // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
  50. sentry: {
  51. widenClientFileUpload: true,
  52. disableServerWebpackPlugin: true,
  53. },
  54. };
  55. const sentryWebpackPluginOptions = {};
  56. // withSentryConfig extends the default Next.js usage of webpack to:
  57. //
  58. // 1. Initialize the SDK on client page load (See `sentry.client.config.ts`)
  59. //
  60. // 2. Upload sourcemaps, using the settings defined in `sentry.properties`.
  61. // Sourcemaps are only uploaded if SENTRY_AUTH_TOKEN is defined.
  62. //
  63. // Irritatingly, Sentry insists that we create empty sentry.server.config.ts and
  64. // sentry.edge.config.ts files, even though we are not using those parts.
  65. module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);