查看Next.js默認(rèn)配置信息的幾種方法
要查看 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)文章
javascript基于prototype實(shí)現(xiàn)類似OOP繼承的方法
這篇文章主要介紹了javascript基于prototype實(shí)現(xiàn)類似OOP繼承的方法,實(shí)例分析了JavaScript使用prototype實(shí)現(xiàn)面向?qū)ο蟪绦蛟O(shè)計(jì)的中類繼承的相關(guān)技巧,需要的朋友可以參考下2015-12-12IE6下出現(xiàn)JavaScript未結(jié)束的字符串常量錯(cuò)誤的解決方法
JavaScript文件只在IE6下出錯(cuò)(“未結(jié)束的字符串常量”)的解決辦法。2010-11-11神奇!js+CSS+DIV實(shí)現(xiàn)文字顏色漸變效果
很神奇!js+CSS+DIV實(shí)現(xiàn)文字顏色漸變效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03JavaScript中如何跳出forEach循環(huán)代碼示例
循環(huán)遍歷一個(gè)元素是開發(fā)中最常見的需求之一,下面這篇文章主要給大家介紹了關(guān)于JavaScript中如何跳出forEach循環(huán)的相關(guān)資料,文章通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-06-06javascrip高級(jí)前端開發(fā)常用的幾個(gè)API示例詳解
這篇文章主要為大家介紹了javascrip高級(jí)前端開發(fā)中常用的幾個(gè)API示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2021-11-11用表格輸出1-1000之間的數(shù)字實(shí)現(xiàn)代碼(附特效)
本文將介紹下用表格輸出1-1000之間的數(shù)字同時(shí)附有特效,感興趣的朋友可以參考下哈,希望對(duì)你有所幫助2013-04-04JavaScript中實(shí)現(xiàn)new的兩種方式引發(fā)的探究
眾所周知JS中new的作用是通過構(gòu)造函數(shù)來創(chuàng)建一個(gè)實(shí)例對(duì)象,這篇文章主要給大家介紹了關(guān)于JavaScript中實(shí)現(xiàn)new的兩種方式引發(fā)的相關(guān)資料,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-05-05List Installed Software Features
List Installed Software Features...2007-06-06