ojkelly/yarn.build

How to bundle a NextJS project

Closed this issue · 2 comments

I wonder if it's possible to easily bundle a NextJS project.

This is how NextJS documents how to host a NextJS application using a Dockerfile: https://nextjs.org/docs/deployment#docker-image

Actually maybe it just works - except no entrypoint.js file is made but you just have to run yarn run start

Anything that can be run by node can be bundled. The bundling process is essentially just removing all local packages the workspace doesn't depend on.

And then if you have package.json#main set, an entrypoint.js file is added at the top level (which bootstraps pnp). This makes the deployment code easier, as you can just run ./entrypoint.js instead of needing to know the exact path - which may change if you move your workspaces around.

It's primarily useful for AWS Lambda, and say Docker.

You can always cd to the workspace and run a yarn script if that's how you need to start your app.