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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const { basePath, assetPrefix } = require('./utils/var-basePath')
  2. const { codeInspectorPlugin } = require('code-inspector-plugin')
  3. const withMDX = require('@next/mdx')({
  4. extension: /\.mdx?$/,
  5. options: {
  6. // If you use remark-gfm, you'll need to use next.config.mjs
  7. // as the package is ESM only
  8. // https://github.com/remarkjs/remark-gfm#install
  9. remarkPlugins: [],
  10. rehypePlugins: [],
  11. // If you use `MDXProvider`, uncomment the following line.
  12. // providerImportSource: "@mdx-js/react",
  13. },
  14. })
  15. const withBundleAnalyzer = require('@next/bundle-analyzer')({
  16. enabled: process.env.ANALYZE === 'true',
  17. })
  18. // the default url to prevent parse url error when running jest
  19. const hasSetWebPrefix = process.env.NEXT_PUBLIC_WEB_PREFIX
  20. const port = process.env.PORT || 3000
  21. const locImageURLs = !hasSetWebPrefix ? [new URL(`http://localhost:${port}/**`), new URL(`http://127.0.0.1:${port}/**`)] : []
  22. const remoteImageURLs = [hasSetWebPrefix ? new URL(`${process.env.NEXT_PUBLIC_WEB_PREFIX}/**`) : '', ...locImageURLs].filter(item => !!item)
  23. /** @type {import('next').NextConfig} */
  24. const nextConfig = {
  25. basePath,
  26. assetPrefix,
  27. webpack: (config, { dev, isServer }) => {
  28. if (dev) {
  29. config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }))
  30. }
  31. return config
  32. },
  33. productionBrowserSourceMaps: false, // enable browser source map generation during the production build
  34. // Configure pageExtensions to include md and mdx
  35. pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
  36. // https://nextjs.org/docs/messages/next-image-unconfigured-host
  37. images: {
  38. remotePatterns: remoteImageURLs.map(remoteImageURL => ({
  39. protocol: remoteImageURL.protocol.replace(':', ''),
  40. hostname: remoteImageURL.hostname,
  41. port: remoteImageURL.port,
  42. pathname: remoteImageURL.pathname,
  43. search: '',
  44. })),
  45. },
  46. experimental: {
  47. },
  48. // fix all before production. Now it slow the develop speed.
  49. eslint: {
  50. // Warning: This allows production builds to successfully complete even if
  51. // your project has ESLint errors.
  52. ignoreDuringBuilds: true,
  53. dirs: ['app', 'bin', 'config', 'context', 'hooks', 'i18n', 'models', 'service', 'test', 'types', 'utils'],
  54. },
  55. typescript: {
  56. // https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
  57. ignoreBuildErrors: true,
  58. },
  59. reactStrictMode: true,
  60. async redirects() {
  61. return [
  62. {
  63. source: '/',
  64. destination: '/apps',
  65. permanent: false,
  66. },
  67. ]
  68. },
  69. output: 'standalone',
  70. }
  71. module.exports = withBundleAnalyzer(withMDX(nextConfig))