deploy-github

  1. 安裝工具 npm i gh-pages

  2. 添加package.json

```json
 "homepage": "https://minilabmemo.github.io/f2e-election-person",
   "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
```
+ "homepage": "https://<youeaccout>.github.io/reponame",  

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
+    "predeploy": "npm run build", 
+    "deploy": "gh-pages -d build"
  },
-d 代表資料夾
gh-pages -d build。//react專案
gh-pages -d dist   //vue專案

3.執行npm run deploy

如果報錯Failed to get remote.origin.url 就代表要先去設定遠端位置

4.到github網站就會看到多了一個分支叫做 gh-pages

5. 文章說還要再進一步配置,但我看已經有預設值了,接著直接去看deployments就可以開啟網站了

Last updated