Webpack:我应该在生产服务器上构建捆绑软件还是在本地构建然后上传? [英] Webpack: Should I build bundle on production server or build it locally and then upload?

查看:48
本文介绍了Webpack:我应该在生产服务器上构建捆绑软件还是在本地构建然后上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在AWS Elastic Beanstalk上部署React应用程序.我使用webpack捆绑了该应用程序.但是,我对生产构建过程中的最佳实践感到有些困惑.我应该使用webpack在本地构建应用程序(使用NODE_ENV = production),然后仅将生成的bundle.js文件以及所有node_modules上传到Elasticbeanstalk实例吗?或者,我应该上传所有源文件,并在部署期间在实际的云AWS服务器上运行webpack吗?

I am deploying a React app on AWS Elastic Beanstalk. I bundle the app using webpack. However, I'm slightly confused about what best practices are from the production build process. Should I build the app locally (with NODE_ENV=production) using webpack, and then just upload the resultant bundle.js file, along with all node_modules to the Elasticbeanstalk instance? Or, should I upload all the source files, and run webpack on the actual cloud AWS server during deployment?

推荐答案

永远不要在本地进行生产(除非您是唯一的开发人员).

You should never build for production locally (unless you're the only developer).

理想情况下,您有一个生成过程,该过程会从git commit手动或自动触发,然后为您生成要生产的项目.

Ideally, you have a build process that gets triggered manually or automatically from a git commit which then builds your project for production for you.

通过使用集中式构建过程,您可以确保所有构建均以相同的方式构建(例如,相同的node版本,相同的npmyarn版本).

By using a centralized build process, you can then be sure that all your builds are built the same way (e.g. same node version, same npm or yarn version).

这篇关于Webpack:我应该在生产服务器上构建捆绑软件还是在本地构建然后上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆