React Production构建是否会自动压缩视频和图像文件?

发布于 2025-02-13 05:50:15 字数 276 浏览 2 评论 0原文

我创建了一个反应应用程序,该应用程序目前已随着生产构建而部署。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反目相谮 2025-02-20 05:50:15

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文