다 만들었으니 깃헙 페이지에 업로드해주자.
npm i gh-pages"build":"react-scripts build" 를 실행하면 내 웹사이트의 prduction ready code(코드 압축, 최적화)를 생성할 수 있다.npm run build"homepage" :"https://leesugyoung.github.io/React-Begin"git remote -v라고 입력하면 레퍼지토리 이름을 확인할 수 있다.)
gh-pages 를 실행시키고,deploy 를 해야 한다는 것을 기억하고 싶지 않으므로, predeploy 커맨드를 추가! "scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"deploy" : "gh-pages -d build", <<<----
"predeploy" : "npm run build" <<<----
},
즉, 콘솔에 npm run deploy 를 입력하면
→ node.js가 predeploy 를 먼저 실행시킴
→ predeploy 는npm run build 를 실행
→ 그리고 npm run build는 react-scripts build 를 실행
→ 최적화 과정이 끝나면 predeploy의 gh-pages -d build 진행
→ 그럼 build 폴더가 제일 하단에 추가했던 "homepage" 웹사이트에 업로드된다.
(build 파일이 github pages에 push 된다.)
function App() {
return (
<Router>
<Routes>
<Route path={process.env.PUBLIC_URL + '/'} element={<Home />} />
<Route path="/movie/:id" element={<Detail />} />
</Routes>
</Router>
);
}