在Heroku上部署React-Redux webpack可以通过以下步骤完成:
Procfile
的文件,该文件用于指定Heroku在部署时要运行的命令。在Procfile
中添加以下内容:
web: npm start
这将告诉Heroku在部署时使用npm start
命令来启动应用程序。
package.json
的文件(如果尚未存在),并确保其中包含以下内容:
{
"name": "your-app-name",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --mode production",
"build": "webpack --mode production"
},
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-redux": "^7.0.0",
"redux": "^4.0.0",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.0",
"webpack-dev-server": "^3.0.0"
}
}
确保所有依赖项都正确地列在dependencies
部分中。
cd
命令导航到项目根目录。
npm install
npm run build
这将使用Webpack将React-Redux项目打包到dist
文件夹中。
git init
git add .
git commit -m "Initial commit"
git remote add heroku <heroku-git-url>
git push heroku master
替换<heroku-git-url>
为你的Heroku应用程序的Git URL。
以上步骤将帮助你在Heroku上成功部署React-Redux webpack应用程序。请注意,这只是一个基本的部署过程,你可能需要根据你的项目的具体要求进行一些调整和配置。
领取专属 10元无门槛券
手把手带您无忧上云