image icon indicating copy to clipboard operation
image copied to clipboard

IPX Static Render Skipped with Custom BaseURL

Open joshualyon opened this issue 1 year ago • 0 comments

When using the default IPX provider, if you've customized the provider's baseURL and it doesn't include /_ipx somewhere in the path, the images are not prerendered when performing a static build.

nuxt.config.ts

export default defineNuxtConfig({
  image: {
    ipxStatic: {
      baseURL: '/static-images'
    }
  }
})

It looks like the /src/runtime/utils/prerender.ts has hardcoded a filter looking for /_ipx/ which is what's causing this: https://github.com/nuxt/image/blob/244f37ef22bfb23e04c994b30de5ba8e56e66fbf/src/runtime/utils/prerender.ts#L4-L12

I'm not intimately familiar with the codebase, but if there's a good way to either pass in the context that includes the current provider or some other good way of determining the provider, it seems like that could be used to determine if the ipxStatic.baseURL from the runtime config should be used.

Alternatively, since the prerender check is already hardcoded for /_ipx/, it might be sufficient to just check if there's a ipxStatic.baseURL in the runtime config and use that for the filter otherwise fallback to /_ipx/

joshualyon avatar Jun 26 '24 15:06 joshualyon