'How to bundle NextJS project into one single file

I'm currently building a project that will work as an addon to another application. I'm currently using NextJS to build the application, but I need to bundle the NextJS JavaScript files into only one. Is that possible?



Solution 1:[1]

next export will export all your pages to static HTML files that you can serve with any host (similarly to create-react-app). You can use this as an addon as you can get your pre-existing application to just render the html files at specific endpoints.

However this doesn't bundle everything into a single .js file, but this is the closest you will get. If next export doesn't satisfy your use case maybe its worth asking why you need to bundle everything into a single js file specifically, and if its just JS you need - then why use Next?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RockiRider