next.config.js 2.0 KB

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