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

next-images support for Next12.x #87

Open
varadan13 opened this issue Oct 5, 2022 · 4 comments
Open

next-images support for Next12.x #87

varadan13 opened this issue Oct 5, 2022 · 4 comments

Comments

@varadan13
Copy link

varadan13 commented Oct 5, 2022

Can someone help me understand if next-images is supported in Next12?

@varadan13 varadan13 changed the title does next-images support Next12.x? next-images support for Next12.x Oct 5, 2022
@arefaslani
Copy link
Member

I have not tried it with Next12 unfortunately. Could you please try it and in case it doesn't, we can think of a fix.

@ESCxjl
Copy link

ESCxjl commented Oct 24, 2022

I have not tried it with Next12 unfortunately. Could you please try it and in case it doesn't, we can think of a fix.

have the same question, When loading the svg image in my project it gives the following error:
image

even if I add @svgr/webpack,it does`t work too. Can you help me?

"next": "12.3.1",
"next-images": "^1.8.4",

@alidcast
Copy link

here's part of my config that works @ESCxjl

const withSvg = config => {
  return {
    ...config, 
    webpack(config) {
      config.module.rules.push({
        test: /\.svg$/i,
        issuer: /\.[jt]sx?$/,
        use: ['@svgr/webpack'],
      })
      return config
    }
  }
}

const withImage = config => {
  return withImages({
    ...config, 
    fileExtensions: ["jpg", "jpeg", "png"]
  })
}

I do see warning about using invalid config property since this plugin requires it top-level

he root value has an unexpected property, fileExtensions, which is not in the list of allowed properties

@zargold
Copy link

zargold commented May 10, 2023

The problem seems to be with this line of code:

if (isServer) {
  return `(require("next/config").default().serverRuntimeConfig.nextImagesAssetPrefix || '') + ${p}`;
}

next/config.default() is deemed undefined and you cannot get .serverRuntimeConfig of undefined.

I think that a workaround/temporary solution would be to pass the nextImagesAssetPrefix directly to the library (rather than try to access it off the serverRuntimeConfig it could be passed as an option/param to the "withImages" function.

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

5 participants