nuxt-modules / og-image

Generate OG Images with Vue templates in Nuxt.

Home Page:https://nuxtseo.com/og-image

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support zero-runtime when prerendering

danielroe opened this issue · comments

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.

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 🤔

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.

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.