[React] 프로젝트 Github Pages로 배포하기

Hayley·2021년 12월 9일
1
post-thumbnail

React 프로젝트 셋팅

  1. 배포할 프로젝트에 npm install -save gh-pages 패키지 설치
  2. package.json 파일에서 아래와 같이 코드 수정 및 추가
    2-1. 홈페이지 주소 수정
    "homepage": "html://{Repository name}.github.io/{프로젝트명}/"
    2-2. 스크립트 추가
    "scripts": {
    "start": "react-scripts start",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build": "react-scripts build",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
    },
  3. npm run build 명령 입력

Github 셋팅

  1. Github > Repository 생성
  2. Settings > GitHub Pages 항목에서 gh-pages 브랜치 선택 후 Save

이후 코드 수정 시 npm run deploy 명령을 입력해주면 재배포

참고 블로그: https://dev-yakuza.posstree.com/ko/react/github-pages/

profile
👩🏻‍💻✍🏻

0개의 댓글