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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }))
  29. return config
  30. },
  31. productionBrowserSourceMaps: false, // enable browser source map generation during the production build
  32. // Configure pageExtensions to include md and mdx
  33. pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
  34. // https://nextjs.org/docs/messages/next-image-unconfigured-host
  35. images: {
  36. remotePatterns: remoteImageURLs.map(remoteImageURL => ({
  37. protocol: remoteImageURL.protocol.replace(':', ''),
  38. hostname: remoteImageURL.hostname,
  39. port: remoteImageURL.port,
  40. pathname: remoteImageURL.pathname,
  41. search: '',
  42. })),
  43. },
  44. experimental: {
  45. },
  46. // fix all before production. Now it slow the develop speed.
  47. eslint: {
  48. // Warning: This allows production builds to successfully complete even if
  49. // your project has ESLint errors.
  50. ignoreDuringBuilds: true,
  51. dirs: ['app', 'bin', 'config', 'context', 'hooks', 'i18n', 'models', 'service', 'test', 'types', 'utils'],
  52. },
  53. typescript: {
  54. // https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
  55. ignoreBuildErrors: true,
  56. },
  57. reactStrictMode: true,
  58. async redirects() {
  59. return [
  60. {
  61. source: '/',
  62. destination: '/apps',
  63. permanent: false,
  64. },
  65. ]
  66. },
  67. output: 'standalone',
  68. }
  69. module.exports = withBundleAnalyzer(withMDX(nextConfig))