next.config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const { withSentryConfig } = require('@sentry/nextjs')
  2. const isDevelopment = process.env.NODE_ENV === 'development'
  3. const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN
  4. const SENTRY_ORG = process.env.NEXT_PUBLIC_SENTRY_ORG
  5. const SENTRY_PROJECT = process.env.NEXT_PUBLIC_SENTRY_PROJECT
  6. const isHideSentry = isDevelopment || !SENTRY_DSN || !SENTRY_ORG || !SENTRY_PROJECT
  7. const withMDX = require('@next/mdx')({
  8. extension: /\.mdx?$/,
  9. options: {
  10. // If you use remark-gfm, you'll need to use next.config.mjs
  11. // as the package is ESM only
  12. // https://github.com/remarkjs/remark-gfm#install
  13. remarkPlugins: [],
  14. rehypePlugins: [],
  15. // If you use `MDXProvider`, uncomment the following line.
  16. // providerImportSource: "@mdx-js/react",
  17. },
  18. })
  19. /** @type {import('next').NextConfig} */
  20. const nextConfig = {
  21. productionBrowserSourceMaps: false, // enable browser source map generation during the production build
  22. // Configure pageExtensions to include md and mdx
  23. pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
  24. experimental: {
  25. appDir: true,
  26. },
  27. // fix all before production. Now it slow the develop speed.
  28. eslint: {
  29. // Warning: This allows production builds to successfully complete even if
  30. // your project has ESLint errors.
  31. ignoreDuringBuilds: true,
  32. },
  33. typescript: {
  34. // https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
  35. ignoreBuildErrors: true,
  36. },
  37. async redirects() {
  38. return [
  39. {
  40. source: '/',
  41. destination: '/apps',
  42. permanent: false,
  43. },
  44. ]
  45. },
  46. ...(isHideSentry
  47. ? {}
  48. : {
  49. sentry: {
  50. hideSourceMaps: true,
  51. },
  52. }),
  53. }
  54. // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup
  55. const sentryWebpackPluginOptions = {
  56. org: SENTRY_ORG,
  57. project: SENTRY_PROJECT,
  58. silent: true, // Suppresses all logs
  59. sourcemaps: {
  60. assets: './**',
  61. ignore: ['./node_modules/**'],
  62. },
  63. // https://github.com/getsentry/sentry-webpack-plugin#options.
  64. }
  65. module.exports = isHideSentry ? withMDX(nextConfig) : withMDX(withSentryConfig(nextConfig, sentryWebpackPluginOptions))