본문 바로가기
etc

React로 개발한 프로젝트 Github로 배포하기

by Zㅣ존수빈zz 2023. 4. 18.

1. github에서 레포지토리 생성

2. 터미널(Ctrl+J)에 npm install gh-pages --save-dev 입력



3. package.json > name과 version 아래 배포할 주소 추가


    "homepage" : "https://{username}.github.io/{repo name}",

    예)     "homepage" : "https://subin9804.github.io/example-repo",



    scripts에서 제일 위에 추가 (배포 전후로 호출할 명령문)
    "predeploy" : "npm run build",
    "deploy" : "gh-pages -d build",


4. 터미널에 git init (프로젝트 폴더를  깃 레포지토리로 만듦)

5. git add *

6. git commit -m "first commit"

7. git branch -M main (main을 메인 브렌치로 지정, 생략가능)

8. git remote add origin https://github.com/subin9804/example-repo (저장할 repository 지정)

9. npm run deploy

댓글