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

IPX Static Render Skipped with Custom BaseURL #1394

Open
joshualyon opened this issue Jun 26, 2024 · 0 comments
Open

IPX Static Render Skipped with Custom BaseURL #1394

joshualyon opened this issue Jun 26, 2024 · 0 comments

Comments

@joshualyon
Copy link

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:

export function prerenderStaticImages(src = '', srcset = '') {
if (!import.meta.server || !process.env.prerender) {
return
}
const paths = [
src,
...srcset.split(', ').map(s => s.trim().split(' ')[0].trim()),
].filter(s => s && s.includes('/_ipx/'))

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/

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

1 participant