在Heroku上部署了Create-Reaction-App,但页面为空白
我正尝试在heroku
上部署react
应用程序,但在Heroku上部署它显示空白页面后,我还使用buildpack mars/create-react-app
以下是我对已部署项目的看法:
这是我的package.json
文件:
{
"name": "covid-19",
"version": "0.1.0",
"private": true,
"homepage": "covid-19-stats-by-anny-v3",
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"express": "^4.17.1",
"fetch": "^1.1.0",
"gh-pages": "^3.1.0",
"material-table": "^1.65.0",
"mui-datatables": "^3.3.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-social-icons": "^4.1.0"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-scripts": "^3.4.1"
}
}
解决方案
此白屏背后的原因是将脚本文件加载到浏览器中。
在您的webpack配置中有Public Path设置,用于告诉应用程序它的根路径是什么。在我们的示例中,这将是https://www.yourwebsite.com/
如果设置正确,它将基于该URL的上述链接,您的应用程序将按预期加载。
将此信息放入Package.json文件在Package.json中的版本之后添加这些行
"homepage":"your app link"
并再次生成应用程序,它将起作用。
相关文章