rsnext/packages/next-bundle-analyzer/readme.md
Tim Neutkens 3e51ddb8af
Move syntax formatting to prettier (#7454)
* Run prettier over packages/**/*.js

* Run prettier over packages/**/*.ts

* Run prettier over examples

* Remove tslint

* Run prettier over examples

* Run prettier over all markdown files

* Run prettier over json files
2019-05-29 13:57:26 +02:00

35 lines
763 B
Markdown

# 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)
```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.