Must Remember
- build 후에 배포하기 위해 package.json에 아래 구문으로 변경해준다.
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
- npm install gh-pages 설치
- package.json에 "homepage": "https://아이디.github.io/Movie_App_2021" 추가
- git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/아이디/Movie_App_2021.git
git push -u origin main
순서로 리포지토리에 업로드
- npm run deploy로 빌드 후 배포
※ 만약 BrowserRouter를 사용했을 경우 basename={process.env.PUBLIC_URL}를 써줘야 Home이 바로 보인다.
<BrowserRouter basename={process.env.PUBLIC_URL}>
<Routes>
<Route path="/" element={<Friends />} />
</Routes>
</BrowserRouter>