rsnext/packages/next-bundle-analyzer/readme.md
Shu Uesugi e1083f0e3a docs: remove --save from npm install; avoid system-ui (#10252)
* Minor edits for CSS doc

* Remove unnecessary --save from npm install

* Different font family

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-27 08:35:12 -05:00

35 lines
756 B
Markdown

# Next.js + Webpack Bundle Analyzer
Use `webpack-bundle-analyzer` in your Next.js project
## Installation
```
npm install @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)
```js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({})
```
Then you can run the command below:
```bash
# 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.