cyrilwanner / next-optimized-images

🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).
MIT License
2.21k stars 93 forks source link

TypeError: unsupported file type: undefined (file: undefined) #284

Closed Jaydeep189 closed 1 year ago

Jaydeep189 commented 2 years ago

error - ./public/logo/amc.png TypeError: unsupported file type: undefined (file: undefined)

This is my next.config.js

I am using imagemin-optipng for optimization

I am building a static site with nextjs



const nextConfig = withOptimizedImages({
  optimizeImagesInDev: true,
  reactStrictMode: true,
  swcMinify: true,
  experimental: {
    images: {
      unoptimized: true,
    },
  },
});
module.exports = nextConfig;
signorbusi commented 2 years ago

I'm facing exactly the same problem

abbasEbadian commented 1 year ago

I used the withPlugins version of .next.config file and set handleImages: ['*'] then the error gone.

hannah26hannah commented 1 year ago

I also encounted this error. I'm using withPlugins as well, and for the default config, I set disableStaticImages inside images as true and luckily it resolved this error.

const nextConfig = {
...
  images : {
    disableStaticImages: true,
  }
...
}
CallumJHays commented 1 year ago

I updated from next@10 to next@12 and ran into this. @abbasEbadian 's fix did silence the error but broke all images.

@hannah26hannah 's fix on the other-hand worked. Cheers!

Jaydeep189 commented 1 year ago
disableStaticImages: true,

It worked! Thanks