freddy38510 / quasar-app-extension-ssg

Static Site Generator App Extension for Quasar.
MIT License
155 stars 16 forks source link

Can't build with both modes: SSG and SSR. #33

Open vandelpavel opened 3 years ago

vandelpavel commented 3 years ago

@freddy38510 I'm trying to split my project and i need it to run half in SSG and the other in SSR. With that in mind my problem comes when i try to split routes and when i'm asking for the MODE i can't search for ssg. Also the portion of code that should run in ssr both runs in ssr and ssg.

Any clues on how to separate things?

(also i'm starting to get familiar with routing and dynamic routes) #22

freddy38510 commented 3 years ago

You're right, you can't combine both modes because i developped this extension with only SSG in mind.

But, the extension should build your app in SSR mode and generate static pages for the routes you provide in SSG options. It could be interesting to add this feature based on router option object.

Right now, i think it will be very difficult to handle both modes by yourself. I mean that the app extension will prevent you to do that easily. So, i have to implement this feature. I can't give you a date of release. I will come back to you to let you know how the things progress.

First, i will try to make available ssg in process.env.MODE quickly.

freddy38510 commented 3 years ago

@vandelpavel

From release 1.1.0 you can use process.env.STATICto conditionnaly do things depending if you're app was built with quasar ssg generate or not.

franco-onevillas commented 2 years ago

Hi @freddy38510, how does the process.env.STATIC help with that?

I mean, if you exclude some routes (to work with SSG), is it going to use the SSR on the rest of the routes?

Thank you :)

freddy38510 commented 2 years ago

It is going to fallback to SPA on the rest of the routes.

SSG + SSR on excluded routes is not implemented yet.

process.env.STATIC can help if you build your app multiple times with different modes.

Out of curiosity, could you explain why you need to build your app with both modes (ssg + ssr) ? Isn't SSG + SPA on excluded routes sufficient for your use-case ?

franco-onevillas commented 2 years ago

Ahh okay, get it!

I would like to use both modes because some pages need fresh data + SEO + cookies + we don't want the spinner UX.

For the rest of the static page, SSG works great.

freddy38510 commented 2 years ago

Ah, that makes sense, thanks for the explanation.

For now, implementing this feature is not a priority. First, I planned to support Vite.js and lazy hydration via a new package I'm working on.

But I will keep your need in mind and let you know when I start making progress.

franco-onevillas commented 2 years ago

Thank you Freddy. Wow, that would help with improving the time to Interactive, right?

Cheers

freddy38510 commented 2 years ago

Yep that's right, in theory it should.

You can also lighten your client bundle with code splitting and only load the splitted chunks when hydration occurs.

In practice, splitted chunks are async components inside the LazyHydrationWrapper or component wrapped with import-wrappers like this:

hydrateNever(() => import('CompA.vue'));

By using the library this way with the ssg extension, the js code for the CompA will never be loaded at client side.

fprl commented 2 years ago

That's a good one. I would love to help with these things, but I never dare to get into OSS...