📘
simpleReact
  • 01. React 시작해보기
  • 02. Componet 구성해보기
  • 03. styled-component 로 스타일링해보기
  • 04. State 와 Props
  • 05. Loop
  • 06. Event
  • 07. Router
  • 08. TODO APP (Read, Create)
  • 09. TODO APP (DELETE)
  • 10. TODO APP (UPDATE - STATUS)
  • Context API
  • NextJS 배포하기 - NextJS, Travis Setup
  • NextJS 배포하기 - Beanstalk
  • Storybook
  • (1) 만들면서 알아보는 Hooks
  • (2) 만들면서 알아보는 Hooks
  • React 배포하기 - Travis, Github Pages
  • Dark Mode
Powered by GitBook
On this page

Was this helpful?

React 배포하기 - Travis, Github Pages

Previous(2) 만들면서 알아보는 HooksNextDark Mode

Last updated 5 years ago

Was this helpful?

먼저 Github Repo 를 만들어주세요

그 후 Create React App 을 이용하여 프로젝트를 생성합니다.

$ npx create-react-app exam-deploy-pages
$ cd exam-deploy-pages
$ npm start 

만들어 놓은 프로젝트를 Github 에 올려주세요

$ git init
$ git add .
$ git commit -m "initial commit"
$ git remote add origin <본인 repo>
$ git push -u origin master

Github Token 을 가져와야합니다. 오른쪽 프로필에서 Settings > Developer settings 에서 토큰을 발급 받습니다.

연결된 Travis 에 우리가 위에서 발급 받은 토큰을 환경변수에 넣어줘야합니다. Settings 으로 들어가주세요

프로젝트 폴더 루트 경로에 .travis.yml 파일을 만들어줍니다.

language: node_js

node_js:
- "11"

cache:
  directories:
    - node_modules

deploy:
  provider: pages
  skip-cleanup: true
  keep-history: true
  github-token: $GITHUB_TOKEN
  local_dir: public
  on:
    branch: master

install:
  - npm install

script:
  - npm run deploy

그리고 gh-pages 모듈을 설치합니다.

$ npm i -D gh-pages

package.json 의 script 에 deploy 명령어와 home page 정보를 추가합니다.

"homepage" : "http://<Github 유저 이름>.github.io/<Github Repo 이름>"
$ git add .
$ git commit -m "bulid script 를 추가합니다"
$ git push origin master 

에 가입 후 만들어 놓은 Github Repo 를 연결해주세요

Travis CI
localhost:3000