How to bundle a React app to a subdirectory on a server?

前端 未结 10 2107
名媛妹妹
名媛妹妹 2020-12-04 14:41

I have a React app I\'ve been developing on my localhost. I want to copy it to a server into a subdirectory called vensa.

My webpack config file looks like this..

10条回答
  •  情深已故
    2020-12-04 15:24

    If you are using React Router v4 you should be able to set it using basename={foobar}.

    
      
    
    

    Link to the docs: https://reacttraining.com/react-router/web/api/BrowserRouter

    Note: if using create-react-app in a sub directory you will also want to set "homepage": "/foobar/", in your package.json file. So the production build points at the right path.

提交回复
热议问题