Nuxt Generate and Nuxt Build
Nuxt comes out-of-the-box with two build tasks: nuxt generate
and nuxt build
. Both of them build your project but in very different ways. For instance, nuxt build
build’s your project into a production-ready bundle that can be deployed on the server and “started.” When using nuxt build
you also need to run npm run start
to start the live server that will read the built project, but nuxt build
only builds the project because they are two separate tasks. With nuxt build
you need a Node.js server for your application to run. You cannot host the build folders on a static host since they will not work.
With nuxt build
you enable rendering-on-the-fly. When a user visits a specific route, the Node.js server will quickly fetch the data, render it, and send it as a static HTML page to the client. Soon after, the application gets hydrated and becomes a single page application and SSR is no longer required.
To run nuxt build
run:
$
npm run build...