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.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const { codeInspectorPlugin } = require('code-inspector-plugin')
  2. const withMDX = require('@next/mdx')({
  3. extension: /\.mdx?$/,
  4. options: {
  5. // If you use remark-gfm, you'll need to use next.config.mjs
  6. // as the package is ESM only
  7. // https://github.com/remarkjs/remark-gfm#install
  8. remarkPlugins: [],
  9. rehypePlugins: [],
  10. // If you use `MDXProvider`, uncomment the following line.
  11. // providerImportSource: "@mdx-js/react",
  12. },
  13. })
  14. const withBundleAnalyzer = require('@next/bundle-analyzer')({
  15. enabled: process.env.ANALYZE === 'true',
  16. })
  17. // the default url to prevent parse url error when running jest
  18. const hasSetWebPrefix = process.env.NEXT_PUBLIC_WEB_PREFIX
  19. const port = process.env.PORT || 3000
  20. const locImageURLs = !hasSetWebPrefix ? [new URL(`http://localhost:${port}/**`), new URL(`http://127.0.0.1:${port}/**`)] : []
  21. const remoteImageURLs = [hasSetWebPrefix ? new URL(`${process.env.NEXT_PUBLIC_WEB_PREFIX}/**`) : '', ...locImageURLs].filter(item => !!item)
  22. /** @type {import('next').NextConfig} */
  23. const nextConfig = {
  24. basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
  25. webpack: (config, { dev, isServer }) => {
  26. if (dev) {
  27. config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }))
  28. }
  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))