Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuxt build --spa vs nuxt generate

Tags:

vue.js

nuxt.js

What is the difference between

nuxt build 

vs

nuxt generate 

vs

nuxt build --spa 

I am trying to compile three different variations:

1. regular nuxt with ssr 2. prerendered spa 3. spa without prerendering 

I am struggling to find the appropriate commands for it

like image 638
Chris Avatar asked Sep 12 '17 11:09

Chris


People also ask

What is Nuxt generate?

nuxt generate - Build the application (if needed), generate every route as a HTML file and statically export to dist/ directory (used for static hosting). nuxt start - serve the dist/ directory like your static hosting would do (Netlify, Vercel, Surge, etc), great for testing before deploying.

Is Nuxt good for spa?

When combined with headless platform such as CrafterCMS, Nuxt can provide a framework to build highly-performant web applications and SPAs. This article is an introductory review of NuxtJS, a powerful framework on top of Vue for building modern web applications.


1 Answers

As shown in the docs, the above commands correspond to:

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).

The --spa flag doesn't seem to be covered in the docs themselves, however the generator help outlines, without further explanation:

Options
--spa Launch in SPA mode


Given this information, it would seem the following commands should cover your needs, however I haven't tested them myself at the moment:

  1. Regular Nuxt with SSR: nuxt build
  2. Prerendered SPA: nuxt generate
  3. SPA without prerendering: nuxt build --spa

Take all of this with a grain of salt, however, as the Nuxt team is notorious for having out-of-date documentation.

like image 113
Etheryte Avatar answered Sep 30 '22 12:09

Etheryte