您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

next.config.js 1.6KB

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