You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

next.config.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // the default url to prevent parse url error when running jest
  16. const hasSetWebPrefix = process.env.NEXT_PUBLIC_WEB_PREFIX
  17. const port = process.env.PORT || 3000
  18. const locImageURLs = !hasSetWebPrefix ? [new URL(`http://localhost:${port}/**`), new URL(`http://127.0.0.1:${port}/**`)] : []
  19. const remoteImageURLs = [hasSetWebPrefix ? new URL(`${process.env.NEXT_PUBLIC_WEB_PREFIX}/**`) : '', ...locImageURLs].filter(item => !!item)
  20. /** @type {import('next').NextConfig} */
  21. const nextConfig = {
  22. basePath,
  23. assetPrefix,
  24. webpack: (config, { dev, isServer }) => {
  25. config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }))
  26. return config
  27. },
  28. productionBrowserSourceMaps: false, // enable browser source map generation during the production build
  29. // Configure pageExtensions to include md and mdx
  30. pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
  31. // https://nextjs.org/docs/messages/next-image-unconfigured-host
  32. images: {
  33. remotePatterns: remoteImageURLs.map(remoteImageURL => ({
  34. protocol: remoteImageURL.protocol.replace(':', ''),
  35. hostname: remoteImageURL.hostname,
  36. port: remoteImageURL.port,
  37. pathname: remoteImageURL.pathname,
  38. search: '',
  39. })),
  40. },
  41. experimental: {
  42. },
  43. // fix all before production. Now it slow the develop speed.
  44. eslint: {
  45. // Warning: This allows production builds to successfully complete even if
  46. // your project has ESLint errors.
  47. ignoreDuringBuilds: true,
  48. dirs: ['app', 'bin', 'config', 'context', 'hooks', 'i18n', 'models', 'service', 'test', 'types', 'utils'],
  49. },
  50. typescript: {
  51. // https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
  52. ignoreBuildErrors: true,
  53. },
  54. reactStrictMode: true,
  55. async redirects() {
  56. return [
  57. {
  58. source: '/',
  59. destination: '/apps',
  60. permanent: false,
  61. },
  62. ]
  63. },
  64. output: 'standalone',
  65. }
  66. module.exports = withMDX(nextConfig)