如何分析 Next.js 應用程式的捆綁檔案

深入了解 Next.js 應用程式捆綁檔案內容的方法。 Next.js 提供了一種分析產生程式碼捆綁檔案的方式。 打開專案的 package.json 檔案,並在 scripts 區塊中新增以下三個指令: "analyze": "cross-env ANALYZE=true next build", "analyze:server": "cross-env BUNDLE\_ANALYZE=server next build", "analyze:browser": "cross-env BUNDLE\_ANALYZE=browser next build" 就像這樣: { "name": "firstproject", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "dev": "next", "build": "next build", "start": "next start", "analyze": "cross-env ANALYZE=true next build", "analyze:server": "cross-env BUNDLE\_ANALYZE=server next build", "analyze:browser": "cross-env BUNDLE\_ANALYZE=browser next build" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "next": "^9....