Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ssr: false #1515

Open
dladeira opened this issue Sep 27, 2024 · 7 comments
Open

Support for ssr: false #1515

dladeira opened this issue Sep 27, 2024 · 7 comments

Comments

@dladeira
Copy link

I am trying to use nuxt-img with electron, but the problem is that electron does not working with ssr, and it seems that this module does not work without server-side rendering (ssr: true).

Is there planned support for ssr: false. Before, in version v0 there seemed to be a static provider (docs), does something like this exist in this version? Where maybe some of the nuxt-img features are dropped, but the images still work with the ssr: false property?

Context, when running with ssr: false ipx does not run, meaning the _ipx folder does not exist, see this issue.

--

The documentation is also rather confusing, from static images

In that case, you can tell Nuxt to pre-render images by using the nitro.prerender.routes option

What does this mean, do I have to loop through all my images, and create an array with a prefix of /_ipx/w_???.

@Baroshem
Copy link
Collaborator

Baroshem commented Dec 7, 2024

@danielroe is this feature somewhere on the roadmap? :)

@danielroe
Copy link
Member

ssr: false means no HTML rendering of your Vue pages and this is not compatible with prerendering a totally static website with image optimisation. nuxt would be unable to know what images to optimise.

(it would work fine if you had a server at runtime)

however, you can statically generate a site without ssr: false. this should work fine. normally using ssr: false when prerendering is a mistake or misunderstanding of how nuxt does ssg.

@dladeira
Copy link
Author

Could generate the optimized images during generation, and then serve them statically? Or perhaps at least make it so the images do load, but there isn't any processing by nuxt-img so the site doesn't break?

@danielroe
Copy link
Member

that’s exactly what ipxStatic does. but it requires you to have ssr: true turned on during static generation.

to reiterate, ssr: true does not mean you have a server at runtime

@dladeira
Copy link
Author

Isn't the whole point of SSR that you have a server at runtime that helps with page rendering? I'm getting that impression from this universal rendering in the wiki

Cost: A server needs to be running in order to render pages on the fly. This adds a monthly cost like any traditional server. However, the server calls are highly reduced thanks to universal rendering with the browser taking over on client-side navigation. A cost reduction is possible by leveraging edge-side-rendering.

@danielroe
Copy link
Member

I'm not sure I understand the point you are making.

You can statically render all your pages without any server at runtime. You need ssr: true to benefit from most of the benefits of this, like SEO or image optimisation. Only very rarely would it ever be correct to use ssr: false with a fully static site. (Possibly in the case of an electron app, like your situation.)

You can also have a server running at runtime. Mostly I would also recommend ssr: true but in the edge case of opting for ssr: false the main benefit you would get is having API routes, like /_ipx.

@dladeira
Copy link
Author

My apologies I'm a bit confused. What is the point of ssr: true, if you don't need to have a server running at runtime? What exactly does it do?

ssr: false means no HTML rendering of your Vue pages and this is not compatible with prerendering a totally static website with image optimisation. nuxt would be unable to know what images to optimise.

Could we not optimize the images, just serve them, so the website doesn't break? Maybe let the users know with a warning that the images aren't being optimized?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants