[TIL] github pages subdirectory 로 배포할 때 react browserRouter 적용

Funnystyle·2021년 4월 20일
0

package.json

{
  ...
  "homepage": "https://domain.github.io/directory-name"
}

Router

<Router basename={'/directory-name'}>
  <Route path='/' component={Home} />
  {/* … */}
</Router>

이렇게 두 가지만 하면 됨.

참고:
https://medium.com/@svinkle/how-to-deploy-a-react-app-to-a-subdirectory-f694d46427c1
==> "step 3 and step 4 not needed" 라는 댓글이 있음

profile
polyglot

0개의 댓글