How to exclude specific routes during Next.js production build

Hi Community :waving_hand:

Problem

While working with Next.js, we are facing a challenge related to the build process. By default, Next.js builds all routes along with their respective CSS and JS files. Because of this, the overall bundle size becomes quite large, even when we only need a few specific routes for a particular build.

Proposed Solution

It would be really helpful if Next.js allowed us to exclude certain routes during the build or build only the required routes based on the use case. This would significantly reduce bundle size and improve performance :rocket:

Has anyone faced a similar issue or found a good approach to handle this? Any suggestions would be greatly appreciated.

Thanks in advance :blush: