简体   繁体   English

如何将Create-React-App构建推送到Heroku?

[英]How to push Create-React-App build to Heroku?

In the past, I've only uploaded my front end applications as static versions using github's GH-Pages. 过去,我只使用github的GH-Pages将前端应用程序上传为静态版本。 This is my first React app and it connects to a backend API that I have uploaded and running on Heroku. 这是我的第一个React应用,它连接到我上传并在Heroku上运行的后端API。

I used Create-React-App to build this app in react. 我在响应中使用Create-React-App来构建此应用程序。 When I command npm run build... Webpack builds out my es5 version of the code so that it can be read by the browser. 当我命令npm run build ... Webpack构建我的es5版本的代码,以便浏览器可以读取它。 So my question is, being this is my first time uploading a front end application on heroku, how do I do this with my react files? 所以我的问题是,这是我第一次在heroku上上传一个前端应用程序,如何使用我的react文件来做到这一点?

Thanks 谢谢

There is a buildpack that will allow you to deploy to heroku with no configuration necessary! 有一个buildpack,可以让您无需配置就可以部署到heroku! See Mars Hall's blog post on the subject at https://blog.heroku.com/deploying-react-with-zero-configuration 请参阅Mars Hall关于该主题的博客文章, 网址https://blog.heroku.com/deploying-react-with-zero-configuration

On the blog you'll find the instructions for deploying a new create-react-app to heroku, but to do it for a pre-existing project... 在博客上,您会找到有关将新的create-react-app部署到heroku的说明,但要针对现有项目进行操作...

cd to your project folder in the terminal and enter the following cd到终端中的项目文件夹,然后输入以下内容

git init 

heroku create YOURPROJECTNAME --buildpack https:/github.com/mars/create-react-app-buildpack.git 
// (creates the heroku project with the create-react-app buildpack specified)

git add . 

git commit -m "YOUR COMMENTS" 

git push heroku master 

heroku open

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

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