quasar-app-extension-ssg icon indicating copy to clipboard operation
quasar-app-extension-ssg copied to clipboard

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

Open vandelpavel opened this issue 4 years ago • 9 comments

@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

vandelpavel avatar Dec 17 '20 13:12 vandelpavel

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 avatar Dec 17 '20 13:12 freddy38510

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

freddy38510 avatar May 17 '21 19:05 freddy38510

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

franco-onevillas avatar Jul 14 '22 12:07 franco-onevillas

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 ?

freddy38510 avatar Jul 15 '22 09:07 freddy38510

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.

franco-onevillas avatar Jul 15 '22 10:07 franco-onevillas

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.

freddy38510 avatar Jul 15 '22 13:07 freddy38510

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

Cheers

franco-onevillas avatar Jul 15 '22 15:07 franco-onevillas

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.

freddy38510 avatar Jul 18 '22 12:07 freddy38510

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

fprl avatar Jul 18 '22 16:07 fprl