4

I'm not sure when to use what.

with nuxt build you get two directories(client & server) that means you are actually deploying node.js server(i.e. express, right?)

with nuxt generate you get .html

It seems both ways you can have good SEO which nuxt aims at. And to me, nuxt generate option seems more consize since it doesn't envolve server.

What am I missing here? Why should I use nuxt build and get server code mixed up?

Guest-01
  • 587
  • 1
  • 4
  • 18
  • 2
    Does this answer your question? [What's the real difference between target: 'static' and target: 'server' in Nuxt 2.14 universal mode?](https://stackoverflow.com/questions/63336570/whats-the-real-difference-between-target-static-and-target-server-in-nuxt) – kissu Feb 24 '22 at 12:51

1 Answers1

7

This is shown in the docs here: https://nuxtjs.org/docs/get-started/commands/

nuxt build: Build your application with webpack and minify the JS & CSS (for production).
nuxt generate: Build the application and generate every route as a HTML file (used for static hosting). Josh

kissu
  • 40,416
  • 14
  • 65
  • 133
Joshua
  • 588
  • 1
  • 5
  • 19
  • 2
    as an addition you can say that nuxt generate will not exist anymore from nuxt 3 on. https://github.com/nuxt/framework/discussions/515 – Jannik Buscha Feb 24 '22 at 09:42
  • in nuxt.config.ts add "ssr: false, target: 'static' ", and then use nuxt generate – riseres Jun 27 '23 at 18:49