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

问题描述 投票:2回答:1

在过去,我只使用github的GH-Pages上传我的前端应用程序作为静态版本。这是我的第一个React应用程序,它连接到我上传并在Heroku上运行的后端API。

我使用Create-React-App来构建这个应用程序。当我命令npm run build ... Webpack构建我的es5版本的代码,以便浏览器可以读取它。所以我的问题是,这是我第一次在heroku上传一个前端应用程序,我该怎么做我的反应文件?

谢谢

javascript reactjs heroku webpack redux
1个回答
4
投票

有一个buildpack,允许你部署到heroku而无需配置!请参阅Mars Hall关于https://blog.heroku.com/deploying-react-with-zero-configuration主题的博客文章

在博客上,您将找到有关将新的create-react-app部署到heroku的说明,但是要为预先存在的项目执行此操作...

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
© www.soinside.com 2019 - 2024. All rights reserved.