universal-vue / uvue

Vue CLI plugin to create universal Vue applications with ease
https://universal-vue.github.io/docs/
MIT License
127 stars 13 forks source link

Prerendered SPA: npm run ssr:static #36

Closed mrksbnch closed 5 years ago

mrksbnch commented 5 years ago

Describe the bug

I want a create a prerendered SPA page (npm run ssr:static) that is using soft reload (using Vue Router in history mode) to link to different pages instead of performing a hard reload.

To Reproduce

Reproduction repo

Expected behavior

If you click on the link in index.html ("Go to subpage"), Vue Router (in history mode) is used to redirect (instead of a hard reload).

Additional context

I want to host a website on Github Pages that needs to keep the store when going to seperate pages (SPA behavior). As I can't use Node.js on Github pages and a hard reload will lose all data that is kept in Vue Store (unless you save that in e.g. localstorange) and is also much slower than a soft reload using Vue Router, I'm wondering if I can generate static HTML files and still use Vue Router to link to different pages (in case JS is enabled)?

Please indicate versions of:

node: 12.4.0
vue-cli: 3.8.2
uvue: 0.1.0-alpha.19
os: macOS 10.14.3
browser: Chrome 73
yabab-dev commented 5 years ago

Maybe I misunderstand you but when you say:

Open index.html file in /dist

Do you use any webserver to open your application or you just open the html file in your browser ?

mrksbnch commented 5 years ago

I'm using a webserver, so the JavaScript / CSS files are correctly loaded (I doubled checked in Chrome Dev Tools and the JavaScript is loaded correctly).

Not really related to that issue but the ability to set a base path (so we don't have to start a webserver every time would be great too to test locally)

yabab-dev commented 5 years ago

Sorry I cannot reproduce it, everything works as expected on my tests: Vue Router handle correclty the navigation when a router link is clicked

mrksbnch commented 5 years ago

@chymz I just noticed that it was a configuration issue on my end and it is indeed working correctly. Sorry!