Skip to content

Commit

Permalink
Update 06-bundle-analyzer.mdx (#64740)
Browse files Browse the repository at this point in the history
The[ existing code
example](https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer)
generates the following warning when using `--turbo` in the current
latest version of NextJS (14.2.2):

⚠ Webpack is configured while Turbopack is not, which may cause
problems.
 ⚠ See instructions if you need to configure Turbopack:
  https://nextjs.org/docs/app/api-reference/next-config-js/turbo

This modification ensures that the bundle analyzer is only applied when
the user intends to generate a report.

Fixes # #64739

---------

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Maxim Svetlakov <maxim@ebookapplications.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
4 people authored Apr 19, 2024
1 parent cf038a3 commit ea0f516
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ pnpm add @next/bundle-analyzer
Then, add the bundle analyzer's settings to your `next.config.js`.

```js filename="next.config.js"
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = withBundleAnalyzer(nextConfig)
const withBundleAnalyzer = require('@next/bundle-analyzer')()

module.exports =
process.env.ANALYZE === 'true' ? withBundleAnalyzer(nextConfig) : nextConfig
```

## Analyzing your bundles
Expand Down

0 comments on commit ea0f516

Please sign in to comment.