nuxt-modules / og-image

Generate OG Images with Vue templates in Nuxt.
https://nuxtseo.com/og-image
360 stars 23 forks source link

support zero-runtime when prerendering #210

Open danielroe opened 1 month ago

danielroe commented 1 month ago

When fully prerendering all static pages, it would be nice to support a mode where there is no server footprint.

For example, in this PR, nuxt-og-image adds some overhead (200kB+ to server runtime, and 1.2Mb+ to node_modules) which ideally I would like to avoid - as in my case I know it is not needed once the pages are prerendered.

harlan-zw commented 1 month ago

This is technically supported already but the DX isn't great and docs are missing.

This is what is used internally when stripping the dependencies:

export default defineNuxtConfig({
  ogImage: {
    compatibility: {
       runtime: {
         'chromium': false,
         'satori': false,
         'css-inline': false,
         'resvg': false,
         'sharp': false,
       }
    }
  }
})

This is less verbose and may also work too (it's a bug if it doesn't):

export default defineNuxtConfig({
  ogImage: {
    compatibility: {
       runtime: {
         satori: false,
       }
    }
  }
})

I'll leave this issue open to document it properly. It would be nice to support a zero-config option for this but seems like it could cause some issues :thinking:

danielroe commented 1 month ago

I think I tried that in the linked PR but it is not sufficient due to other runtime code that is added, such as for nuxt-site-config, a Nuxt content integration, and possibly other plugins.

harlan-zw commented 6 days ago

I'd like to support this but it's partially blocked by Nuxt Kit tooling.

Ideally, we'd be able to register routes or plugins that only register during prerender.

It can be solved but will require migrating to dynamic templates that noop out for non-prerender environments, I'd like to avoid adding this complexity to the templates at this time.