gh-pages를 이용한 github.io에 게시하기

ng-pages

설치

1
$ npm i gh-pages

package.json 설정

“homepage”추가

http://<github ID>.github.io/<Repository Name>

1
2
3
4
"name": "coin_explorer",
"version": "0.1.0",
...
"homepage": "https://hicucu.github.io/ReactjsStudy-CoinExplorer/"

script에 deploy, predeploy 추가

1
2
3
4
5
6
7
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
...
"deploy" : "gh-pages -d build",
"predeploy" : "npm run build"
},

실행

1
$ npm run deploy

deploy를 실행하면 predeploy가 먼저 동작하면서 build가 이루어지고 deploy가 됨

기타

| https://hicucu.github.io/ReactjsStudy-CoinExplorer

react-router-dom을 이용하여 routing을 구현하였지만 github 페이지에서는 라우팅설정이 안되서 정상적으로 동작하지는 않음

주소로 들어가서 메뉴 클릭으로 페이지 이동은 가능하지만 새로고침을 누르거나

https://hicucu.github.io/ReactjsStudy-CoinExplorer/coins 와 같은 주소를 직접 입력하면 404발생

그냥 가벼운 데모 정도로 사용하는 것 이상은 어렵지만 그거라도 감지덕지

#
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×