본문 바로가기
dev/React

React를 Github page 배포하기 (github.io)

by Kyulee 2022. 2. 25.
반응형

Github 프로젝트 업로드

git init - 프로젝트에 git설치
git add * - .gitignore에 있는 파일 제외하고 모두 올리기
git commit -m 'Initial Commit' // 커밋 - 메시지를 입입력
git remote add origin <https://github.com/{gitID}/{react-project-name}.git> - git 저장소 연결
git push -u origin main - git main 브랜치에 push

프로젝트를 Github 레포지토리에 올린다.

 

반응형

npm 페키지

$ npm install --save gh-pages

npm로 github page 페키지 설치, 설치가 완료되면 프로젝트에 있는 package.json 파일을 수정해준다.

 

Package.json 수정

"homepage" 주소를 추가

"homepage": "http://{gitID}.github.io/{react-project-name}"

script 부분에 predeploy, deploy를 추가

"scripts": {..."predeploy": "npm run build",
			"deploy": "gh-pages -d build"}

저장하고 터미널창을 열어 npm run deploy를 실행한다.

 

반응형