首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将React部署到GitHub页

将React部署到GitHub页
EN

Stack Overflow用户
提问于 2017-07-23 07:39:06
回答 2查看 789关注 0票数 2

我遵循了以下教程:

https://pages.github.com/

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment

现在我的存储库名称是: username.github.io用户名替换为我的用户名。

我对应该放在package.json文件上的内容感到困惑,因为它与React deploy教程冲突。这就是我现在用我的用户名替换的用户名

代码语言:javascript
复制
{
    "name": "personal-website",
    "homepage": "https://username.github.io",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "gh-pages": "^1.0.0",
      "react": "^15.6.1",
      "react-bootstrap": "^0.31.1",
      "react-dom": "^15.6.1",
      "react-scripts": "1.0.10"
    },
    "scripts": {
      "predeploy": "npm run build",
      "deploy": "gh-pages -d build",
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test --env=jsdom",
      "eject": "react-scripts eject"
    }
}

每次我加载到username.github.io页面时,它只显示README.md文件,而不显示实际的React应用程序。我的index.html文件必须在公共目录中,否则npm start将无法正确加载。对如何解决这个问题有什么建议吗?

EN

回答 2

Stack Overflow用户

发布于 2017-07-23 07:44:05

您可以使用https://github.com/shinnn/gulp-gh-pages。我自己使用该库将react应用程序部署到github页面:https://github.com/madnight/githut/blob/master/gulpfile.babel.js

票数 0
EN

Stack Overflow用户

发布于 2017-07-24 06:27:04

我不想在GitHub之后添加扩展名。因此,我最终改用了浪涌:http://jakewiesler.com/surge-vs-github-pages-deploying-a-create-react-app-project/

它很好用,而且非常容易使用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45260267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档