Published 2022-07-25

Next.js - Integrate Bundle Analyzer

npm install @next/bundle-analyzer -D

修改next.config.js

const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true'
})

module.exports = withBundleAnalyzer({
  //...other config
})
ANALYZE=true npm run build

nNFdXu

修改package.json

{
  "scripts": {
    "analyze": "ANALYZE=true next build"
  }
}

npm run analyze