简体   繁体   English

如何准备 KOA/Node.js 进行生产?

[英]How to prepare KOA / Node.js for production?

I am using mostly React,我主要使用 React,

and there is a build directory, that will be deployed in the server.并且有一个构建目录,它将部署在服务器中。 It contains minifyed files and excludes development dependancies.它包含缩小的文件并排除开发依赖项。

So my question is - is it advisable or best practice at all to bundle also the same way KOA/NodeJS framework that is serving the server?所以我的问题是 - 以同样的方式捆绑服务于服务器的 KOA/NodeJS 框架是可取的还是最佳实践?

Front-end scripts are often minified and bundled because loading every file on every page load is wasteful and slow.前端脚本通常被缩小和捆绑,因为在每次页面加载时加载每个文件既浪费又缓慢。 It is more efficient to transfer a single large file than many small ones, although this is different in some cases under HTTP2.传输单个大文件比传输许多小文件效率更高,尽管在 HTTP2 下的某些情况下会有所不同。

Your Koa app is server side.你的 Koa 应用程序是服务器端的。 Files are loaded from disk once when your app starts.当您的应用程序启动时,文件会从磁盘加载一次。 Both of these contribute to it making no sense to make a bundle out of your code and dependencies.这两者都导致将代码和依赖项捆绑在一起毫无意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM