본문 바로가기
카테고리 없음

깃허브에 내가 올린 코드 배포하기

by james_janghun 2024. 11. 13.

1. package.json을 수정한다.

homepage와 browserslist 키 아래 추가한다.

  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ], # 콤마 추가
    "homepage": "https://[계정명].github.io/[리포지터리 명]" # 여기 추가
  }

 

scripts 변경

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "predeploy": 'npm run build",  # 추가
    "deploy": "gh-pages -d build"  # 추가
  },

 

gh-pages 설치

프로젝트 루트 경로에서 설치합니다.

npm install gh-pages

 

 

깃허브 경로 제대로 설정했는지 확인

git remote -v

배포

본인 터미널에서 진행

npm run deploy