You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

next.config.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* eslint-disable @typescript-eslint/no-var-requires */
  2. const withPWA = require('next-pwa')
  3. const SentryWebpackPlugin = require('@sentry/webpack-plugin')
  4. const withTM = require('next-transpile-modules')(['@tldraw/tldraw', '@tldraw/core'])
  5. const {
  6. GITHUB_ID,
  7. GITHUB_SECRET,
  8. GITHUB_API_SECRET,
  9. NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
  10. SENTRY_ORG,
  11. SENTRY_PROJECT,
  12. SENTRY_AUTH_TOKEN,
  13. NODE_ENV,
  14. VERCEL_GIT_COMMIT_SHA,
  15. GA_MEASUREMENT_ID,
  16. } = process.env
  17. process.env.SENTRY_DSN = SENTRY_DSN
  18. const isProduction = NODE_ENV === 'production'
  19. const basePath = ''
  20. module.exports = withPWA(
  21. withTM({
  22. reactStrictMode: true,
  23. pwa: {
  24. disable: !isProduction,
  25. dest: 'public',
  26. },
  27. productionBrowserSourceMaps: true,
  28. env: {
  29. NEXT_PUBLIC_COMMIT_SHA: VERCEL_GIT_COMMIT_SHA,
  30. GA_MEASUREMENT_ID,
  31. GITHUB_ID,
  32. GITHUB_SECRET,
  33. GITHUB_API_SECRET,
  34. },
  35. webpack: (config, options) => {
  36. if (!options.isServer) {
  37. config.resolve.alias['@sentry/node'] = '@sentry/browser'
  38. }
  39. config.plugins.push(
  40. new options.webpack.DefinePlugin({
  41. 'process.env.NEXT_IS_SERVER': JSON.stringify(options.isServer.toString()),
  42. })
  43. )
  44. if (
  45. SENTRY_DSN &&
  46. SENTRY_ORG &&
  47. SENTRY_PROJECT &&
  48. SENTRY_AUTH_TOKEN &&
  49. VERCEL_GIT_COMMIT_SHA &&
  50. isProduction
  51. ) {
  52. config.plugins.push(
  53. new SentryWebpackPlugin({
  54. include: '.next',
  55. ignore: ['node_modules'],
  56. stripPrefix: ['webpack://_N_E/'],
  57. urlPrefix: `~${basePath}/_next`,
  58. release: VERCEL_GIT_COMMIT_SHA,
  59. authToken: SENTRY_AUTH_TOKEN,
  60. org: SENTRY_PROJECT,
  61. project: SENTRY_ORG,
  62. })
  63. )
  64. }
  65. return config
  66. },
  67. })
  68. )