출처 https://create-react-app.dev/docs/deployment#github-pages
CRA환경의 프로젝트를 GitHub Pages로 배포하기 위해서는 gh-pages
를 별도로 설치해줘야 한다.
npm install --save gh-pages
package.json 파일에 homepage
필드를 추가하고 GitHub Pages 주소를 적어준다.
CRA는 이 homepage
를 통해서 루트 URL을 결정한다.
"homepage": "https://myusername.github.io/my-app"
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
predeploy
는 deploy
가 실행되기 전에 자동으로 실행된다.
npm run deploy
앞서 scripts에 작성해둔 deploy
에 해당하는 명령어가 자동 실행된다.
배포 완료 시 Published
됐다고 알려줌
settings-GitHub Pages-Source에서 branch
를 gh-pages
로 변경해준다.