Commit f9e4f186 authored by Qurage's avatar Qurage Committed by Tim Neutkens

Update example analyze bundles (#9645)

* Update analyze-bundles example

* follow these updates:
  1. `server` and `browser` options
    * https://github.com/zeit/next-plugins/blob/9ecca7b492518464897ea866b4abcdc6214bf705/packages/next-bundle-analyzer/index.js
  2. "Deprecate next-bundle-analyzer"
    * https://github.com/zeit/next-plugins/commit/e453804d07f309d8b22e11930aa08a260f86108d#diff-5cea9b17189292d8fedc98eeda86bb0b
  3. "Move next-bundle-analyzer to Next.js repo"
    * https://github.com/zeit/next.js/commit/42cff0a09c4ae42016500b1797ae4f0bd8438e88#diff-4e57124572a8e05f52d373c300523f6a
    * "Remove options from bundle-analyzer"

* Support Windows in analyze bundles example

* Remove empty webpack config from analyze bundle example

* https://github.com/zeit/next.js/pull/9645/files/4943d844cc4bd73edfc58ae10d781def3de687af#r354844766
parent a557b7e7
...@@ -39,16 +39,12 @@ yarn dev ...@@ -39,16 +39,12 @@ yarn dev
## The idea behind the example ## The idea behind the example
This example shows how to analyze the output bundles using [@zeit/next-bundle-analyzer](https://github.com/zeit/next-plugins/tree/master/packages/next-bundle-analyzer) This example shows how to analyze the output bundles using [@next/bundle-analyzer](https://github.com/zeit/next.js/tree/master/packages/next-bundle-analyzer)
To analyze your webpack output, invoke the following command: To analyze your webpack output, invoke the following command:
```bash ```bash
npm run analyze npm run analyze
npm run analyze:server
npm run analyze:browser
# or # or
yarn analyze yarn analyze
yarn analyze:server
yarn analyze:browser
``` ```
const withBundleAnalyzer = require('@zeit/next-bundle-analyzer') const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const nextConfig = { const nextConfig = {
analyzeServer: ['server', 'both'].includes(process.env.BUNDLE_ANALYZE), // any configs you need
analyzeBrowser: ['browser', 'both'].includes(process.env.BUNDLE_ANALYZE),
bundleAnalyzerConfig: {
server: {
analyzerMode: 'static',
reportFilename: '../bundles/server.html',
},
browser: {
analyzerMode: 'static',
reportFilename: '../bundles/client.html',
},
},
webpack(config) {
return config
},
} }
module.exports = withBundleAnalyzer(nextConfig) module.exports = withBundleAnalyzer(nextConfig)
...@@ -5,12 +5,11 @@ ...@@ -5,12 +5,11 @@
"dev": "next", "dev": "next",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"analyze": "BUNDLE_ANALYZE=both next build", "analyze": "cross-env ANALYZE=true yarn build"
"analyze:server": "BUNDLE_ANALYZE=server next build",
"analyze:browser": "BUNDLE_ANALYZE=browser next build"
}, },
"dependencies": { "dependencies": {
"@zeit/next-bundle-analyzer": "^0.1.2", "@next/bundle-analyzer": "^9.1.4",
"cross-env": "^6.0.3",
"faker": "^4.1.0", "faker": "^4.1.0",
"next": "latest", "next": "latest",
"react": "^16.7.0", "react": "^16.7.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment