[英]Next.js 11 - Image optimization is not working on production environment
I have a little issue with Image component in Next.js.我对 Next.js 中的 Image 组件有一点问题。 I am using next 11.0.1 version, and I did not find any problems during development and local environment.
我使用的是next 11.0.1版本,在开发和本地环境中没有发现任何问题。 The images are being optimized and everything is working fine.
图像正在优化,一切正常。 However, team and I find out that the images are not being optimized when the site is deployed on production.
但是,我和团队发现,在将站点部署到生产环境时,图像并没有得到优化。 We are using Amazon services to do that.
我们正在使用亚马逊服务来做到这一点。
Here is the proof of what I mean by this:这是我的意思的证明:
On wide-screen (1024px width)
Rendered size: 50 x 50 px
File size: 1.3 kB
On wide-screen (1024px width)
Rendered size: 512 x 512 px
File size: 41.5 kB
Of course, this is not a huge difference, but still I want to know how to fix this issue on production environment.当然,这并不是一个巨大的差异,但我仍然想知道如何在生产环境中解决这个问题。 I also added sharp dependency on the project itself, as I know that it will boost the performance of loading the images on the page.
我还添加了对项目本身的强烈依赖,因为我知道它会提高在页面上加载图像的性能。 Can the problem be with Amazon not being set up properly?
问题可能出在亚马逊设置不正确吗?
module.exports = {
reactStrictMode: true,
images: {
domains: ['avatars.slack-edge.com'],
},
};
Can you check your image source URL length.你能检查你的图像源 URL 长度吗? Because I had same issue in one of my project and when I optimized the url it worked.
因为我在我的一个项目中遇到了同样的问题,当我优化 url 时它起作用了。 You can check the documentation as there is a limit for maximum of string length of 4,096 in redirect.
您可以查看文档,因为重定向中的最大字符串长度限制为 4,096。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.