未验证 提交 42cff0a0 编写于 作者: J JJ Kasper 提交者: GitHub

Move next-bundle-analyzer to Next.js repo (#6445)

* Move next-bundle-analyzer to Next.js repo

* Remove options from bundle-analyzer
上级 cc2b7bc8
module.exports = ({ enabled = true } = {}) => (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack (config, options) {
if (enabled) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: options.isServer ? '../analyze/server.html' : './analyze/client.html'
})
)
}
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}
{
"name": "@next/bundle-analyzer",
"version": "0.0.1",
"main": "index.js",
"license": "MIT",
"repository": {
"url" : "zeit/next.js",
"directory": "packages/next-bundle-analyzer"
},
"dependencies": {
"webpack-bundle-analyzer": "3.0.3"
}
}
# 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.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册