vuejs / vue-hackernews-2.0

HackerNews clone built with Vue 2.0, vue-router & vuex, with server-side rendering
MIT License
10.96k stars 2.15k forks source link

ability to disable SSR #264

Open yehosef opened 6 years ago

yehosef commented 6 years ago

I am learning how this works with the SSR and hydration, also to compare the two approaches with benchmarks .It would be helpful to have the ability to disable the SSR (either with a config option - or at least instructions on what changes to make in the files.)

JounQin commented 6 years ago

It is very easy to implement it by yourself, just generate index.html by html-webpack-plugin, and add some logic about what path should be redirected to index.html, then that's almost finished.

Just remember bootstrap entry-client.js will be a little different between SSR and non-SSR mode, because you only need to wait for router ready for SSR.

Here is a example:

Logic about intercept non-ssr request https://github.com/JounQin/vue-ssr/blob/master/server/index.js#L73

Handle difference about router ready on client https://github.com/JounQin/vue-ssr/blob/master/src/entry-client.js#L68

And also if you like to implement web site static, you can also check here: https://github.com/JounQin/vue-ssr/blob/master/server/index.js#L85