[github] github pages

dev stefanCho·2021년 10월 30일
0

git

목록 보기
10/14

react로 github page를 만드는 방법은 react-gh-pages에 자세히 나와있다.

간략하게 정리하면

  1. cra로 프로젝트를 만들고, npm install gh-pages --save-dev
  2. package.json을 수정한다.
"homepage": "http://devstefancho.github.io/profile",
"scripts": {
  //...
  "predeploy": "npm run build",
  "deploy": "gh-pages -d build"
}
  1. git remote를 추가한다.
  2. npm run deploy로 배포를 한다.

수정한 소스코드를 git push를 하지 않고, npm run deploy만 해줘도 되지만, 이런 경우 깃헙에 이전 소스가 캐싱되어, 페이지가 이전버전으로 보이는 듯하다. 이런 경우는 Empty cache and Hard Reload를 해줘야한다.


github settting

settings > Pages 에서 Source Branch를 gh-pages로 바꿔준다.

참고사항

(만약 git push를 한다면, 자동으로 github에서 퍼지를 해주는 것 같다.)

profile
Front-end Developer

0개의 댓글