欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

查看Next.js默認(rèn)配置信息的幾種方法

 更新時(shí)間:2025年02月21日 10:06:38   作者:南藍(lán)  
文章介紹了幾種查看Next.js默認(rèn)配置信息的方法,包括使用Next.js CLI、getConfigAPI、實(shí)驗(yàn)性CLI命令以及在開發(fā)模式下訪問特定路徑,感興趣的小伙伴跟著小編一起來看看吧

要查看 Next.js 的默認(rèn)配置信息,有幾種方法:

使用 Next.js CLI

next info

通過代碼打印配置

//  next.config.js
   module.exports = (phase, { defaultConfig }) => {
      console.log('Default Next.js config:', defaultConfig)
      return {
        // your custom config
      }
    }

使用 getConfig API

    // config.ts
   import { getConfig } from 'next/config'
    export default function handler(req, res) {
      const nextConfig = getConfig()
      res.status(200).json(nextConfig)
    }

查看運(yùn)行時(shí)配置

  //  page.tsx
  import { useRouter } from 'next/router'
    export default function Page() {
      // 在客戶端查看運(yùn)行時(shí)配置
      console.log(process.env.NEXT_PUBLIC_RUNTIME_CONFIG)
      return <div>...</div>
    }

使用實(shí)驗(yàn)性 CLI 命令(如果可用)

next inspect

// next.config.js
{
  env: {},
  webpack: null,
  webpackDevMiddleware: null,
  distDir: '.next',
  assetPrefix: '',
  configOrigin: 'default',
  useFileSystemPublicRoutes: true,
  generateBuildId: () => null,
  generateEtags: true,
  pageExtensions: ['tsx', 'ts', 'jsx', 'js'],
  target: 'server',
  poweredByHeader: true,
  compress: true,
  analyticsId: process.env.VERCEL_ANALYTICS_ID || '',
  images: {
    deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
    imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
    path: '/_next/image',
    loader: 'default',
    domains: [],
    disableStaticImages: false,
    minimumCacheTTL: 60,
    formats: ['image/webp'],
  },
  devIndicators: {
    buildActivity: true,
    buildActivityPosition: 'bottom-right',
  },
  onDemandEntries: {
    maxInactiveAge: 15 * 1000,
    pagesBufferLength: 2,
  },
  amp: {
    canonicalBase: '',
  },
  basePath: '',
  sassOptions: {},
  trailingSlash: false,
  i18n: null,
  productionBrowserSourceMaps: false,
  optimizeFonts: true,
  webpack5: undefined,
  excludeDefaultMomentLocales: true,
  serverRuntimeConfig: {},
  publicRuntimeConfig: {},
  reactStrictMode: false,
  httpAgentOptions: {
    keepAlive: true,
  },
  outputFileTracing: true,
  staticPageGenerationTimeout: 60,
  swcMinify: true,
  output: 'standalone',
  experimental: {
    // 實(shí)驗(yàn)性功能配置
  }
}

要查看完整的運(yùn)行時(shí)配置,也可以:

  • 在開發(fā)模式下啟動(dòng)項(xiàng)目

    pnpm dev

  • 訪問以下路徑:

    http://localhost:3000/_next/config (試了無效)

到此這篇關(guān)于查看Next.js默認(rèn)配置信息的幾種方法的文章就介紹到這了,更多相關(guān)查看Next.js配置信息內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論