Relative path in index.html after build

后端 未结 3 890
南旧
南旧 2020-12-14 13:56

Hello i have a reactjs app, and I build my project with bellow command

npm build

Here is my package.json file:



        
相关标签:
3条回答
  • 2020-12-14 14:23
    // package.json
    {
      "name": "your-project-name",
      "version": "0.1.0",
      "homepage": "./", # <--- Add this line ----
      ...
    }
    

    Run npm run build again.

    This will change the path to ./, which is the relative path of your project.

    0 讨论(0)
  • 2020-12-14 14:37

    I encountered a similar issue and resolved it by setting "homepage": "./" in package.json

    I found this solution here https://github.com/facebook/create-react-app/issues/165

    0 讨论(0)
  • 2020-12-14 14:47

    If you're using webpack, you can try setting publicPath to ./

    You can read more about it here.

    0 讨论(0)
提交回复
热议问题