美文网首页前端攻城狮
把create-react-app部署到github pages

把create-react-app部署到github pages

作者: 黄一倚 | 来源:发表于2018-12-16 22:35 被阅读104次

添加github pages的部署工具到app上

  • npm install gh-pages --save-dev

配置app中的package.json文件

  "name": "todolist",
  "version": "0.1.0",
  "private": true,
  "homepage": "./",  //加上这一句
"scripts": {
+   "predeploy": "npm run build",    //加上这句
+   "deploy": "gh-pages -d build",    //加上这句
    "start": "react-scripts start",
    "build": "react-scripts build",

在命令行中运行以下指令

  • npm run deploy

剩下的就是在github上把分支设置成github pages就可以了。
我的小案例 todolist

相关文章

网友评论

    本文标题:把create-react-app部署到github pages

    本文链接:https://www.haomeiwen.com/subject/illfkqtx.html