Nuxt.js: generate with spa mode generates html with no static content

Created on 6 Dec 2018  路  7Comments  路  Source: nuxt/nuxt.js

Version

v2.3.4

Reproduction link

generate --spa

Steps to reproduce

Run generate --spa to produce static html files

What is expected ?

html files with static pre rendered content for seo, bots, etc...

What is actually happening?

html files generated only contains the minimal basic of javascript files.

Additional comments?

This is a little confusing to me. And it seems that this is not fully documented. I've seen #4036 #2472. But I'm not really sure what to make of this.

Apparently you need the ssr to generate the html files with static pre rendered content?
Static html files with static pre rendered content - that for me was the main pitch using nuxt. But that is barred behind the build mode settings without an explanation. Maybe consider adding an option to generate pre rendered content which can then throw an error if used in conjunction with spa mode.

Please clarify :)

This bug report is available on Nuxt community (#c8272)
bug-report

Most helpful comment

There is a difference between nuxt generate (--universal) and nuxt generate --spa

When you use nuxt generate in universal mode, it'll save a "snapshot" of the server-rendered HTML and save it as file. That means you have the HTML that usually will be provided by the server statically available and the page will still work as an SPA.

With the nuxt generate --spa flag you'd generate a "traditional" SPA without having the prerendered HTML.

All 7 comments

I have the same problem , use mode spa has no static content, it is the same with the content after run build command.
when I use the mode 'univesal', the page of js can not worked

I have resolve this problem ,this is my nuxt.config.js

  router: {
    mode: 'hash',
    base: '/dist/'
  },
  mode: 'universal',

You probably just want nuxt generate, don't you? 馃

yes, ssr consume more server resource锛孖 want prerender html as a skeleton when build app.
but call api in client not server.

There is a difference between nuxt generate (--universal) and nuxt generate --spa

When you use nuxt generate in universal mode, it'll save a "snapshot" of the server-rendered HTML and save it as file. That means you have the HTML that usually will be provided by the server statically available and the page will still work as an SPA.

With the nuxt generate --spa flag you'd generate a "traditional" SPA without having the prerendered HTML.

right,it works well for me

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredreich picture jaredreich  路  3Comments

msudgh picture msudgh  路  3Comments

maicong picture maicong  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

bimohxh picture bimohxh  路  3Comments