React Production构建是否会自动压缩视频和图像文件?
我创建了一个反应应用程序,该应用程序目前已随着生产构建而部署。
yarn run build
serve -S build
好吧,我知道它会压缩.js
和.scss
文件,然后创建构建文件夹,然后使用。
问题是它会压缩图像&视频文件也是吗?如果不是,我该怎么做?因为我正在从事的项目有很多图像& Vidoes文件对性能产生了很大影响,并且非常缓慢地加载页面。
请帮助您...
I have created a react application which is right now deployed with the production build.
yarn run build
serve -S build
Well I know it compresses the .js
and .scss
files and creates a build folder then serve.
The issue is does it compresses the images & videos files as well? If not how can I do that? because the project I am working on has a lot's of images & vidoes files which impacts a lot on performance and loads the page very slowly.
Kindly help with this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
React不做那些事情。这只是开发的框架。
处理这些内容是Web服务器的责任,即在您的情况下,服务。
但是,即便如此,Web服务器不对资产(字体,图像,视频,音频等)应用其他压缩是一种常见的做法,因为它们首先已经被压缩了。
以图像为例,诸如JPG,PNG,WebP之类的常见文件格式被压缩。除非您提供BMP或RAW,否则您不应该使用,否则Web服务器可以对其应用任何压缩。
React doesn't do those stuff. It is just a framework for development.
It is the web server's responsibility to handle those stuff, i.e.
serve
in your case.But even that, it is a common practice that web servers don't apply additional compression to assets (fonts, images, videos, audios, etc.), because they are already compressed in the first place.
Take images as an example, common file formats like JPG, PNG, WEBP are compressed. Unless you are serving BMP or RAW, which you shouldn't, there is no point for web servers to apply any compressions to them.