Skip to content

Files

Latest commit

5a54e87 · Jul 19, 2019

History

History
This branch is 24021 commits behind vercel/next.js:canary.

next-bundle-analyzer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 29, 2019
Jul 19, 2019
May 29, 2019

Next.js + Webpack Bundle Analyzer

Use webpack-bundle-analyzer in your Next.js project

Installation

npm install --save @next/bundle-analyzer

or

yarn add @next/bundle-analyzer

Usage with environment variables

Create a next.config.js (and make sure you have next-bundle-analyzer set up)

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

Then you can run the command below:

# Analyze is done on build when env var is set
ANALYZE=true yarn build

When enabled two HTML files (client.html and server.html) will be outputted to <distDir>/analyze/. One will be for the server bundle, one for the browser bundle.