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
修改package.json
{
"scripts": {
"analyze": "ANALYZE=true next build"
}
}
npm run analyze