Published: 18 Sept 2022 › Updated: 18 Sept 2022
next.js with webpack bundle analyzer
When you deploy a service,
you should try to reduce the package size. You can use webpack bundle analyzer to check the package size.
I tried to setup next.js with webpack bundle analyzer, but the setup failed.
No search results were found for the above combination.
So, I used the package below.
@next/bundle-analyzer
https://github.com/vercel/next.js/tree/canary/packages/next-bundle-analyzer
It exists on the next.js github page.
Here are a few notes to keep in mind while setting it up.
- I recommend using next-compose-plugins to configure packages dynamically.
- It took me a while to find this setting.
Configure the package referring to the settings below.
package.json
"scripts": {
...
"analyze": "ANALYZE=true next build"
},
"devDependencies": {
...
"next-compose-plugins": "^2.2.1",
"@next/bundle-analyzer": "^12.3.0",
}
next.config.js
/** @type {import('next').NextConfig} */
const withPlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withPlugins([[withBundleAnalyzer]], {
reactStrictMode: false,
compress: true,
});
run
% yarn analyze
Leave next.js with webpack bundle analyzer to:
Read more #hive-152717 posts
Best Posts From suseona
We have not curated any of pishio's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From suseona
- Grid Bot Trading
- Write on blog.suseona.com and Get 100% Upvotes from @pishio!
- Security Update: Stronger Protection for Your Hive Keys
- AI Summary and Q&A Feature Now Available on blog.suseona.com
- AI Summary and Q&A Feature Now Available
- Suseona Weekly Contest – Week 1
- blog.suseona.com updates
- Hive Note MCP in the Claude Code
- Discovering Hive Note!
- The Rollercoaster of Trading: Chasing Profits in the Digital Wild West