cyrilwanner / next-optimized-images

🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Jaydeep189 opened this issue · comments

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;

I'm facing exactly the same problem

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

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,
  }
...
}

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!

disableStaticImages: true,

It worked!
Thanks