更新反应脚本后如何修复主页上的重大更改(创建反应应用程序)
How to fix breaking change on homepage after update react-scripts (create react app)
根据 ,我已将 react-scripts 从 v1.1.4 更新到 v3.4.3。但是,主页上有一个问题我无法正确解决。
在前面package.json,我有"homepage": "/temp_project/resources"
在我将 react-scripts 更新到 v3.4.3 之后,一切正常,除了
当 npm start ("start": "react-scripts start"
) 时,路径将变为 http://localhost:3000/temp_project/resources
这不是预期的。 (预计有 http://localhost:3000/ )
Hot fix = 每次手动更改路径到 http://localhost:3000/
如果我将 "homepage": "/temp_project/resources"
更改为 "homepage": "/"
,那么我的 http://localhost:8080/temp_project(索引页)将变为空白页。我的 npm start ("start": "react-scripts start"
) 工作正常。
我该怎么办??对不起,如果这是一个愚蠢的问题。谢谢。
补充:
这是一个 Maven spring 引导项目,使用 eirslett/frontend-maven-plugin
和 maven-resources-plugin
package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8080",
"homepage": "/temp_project/resources",
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
你能试试 "homepage": "."
或者 "homepage": "./"
吗...如果有帮助请告诉我
根据
在前面package.json,我有"homepage": "/temp_project/resources"
在我将 react-scripts 更新到 v3.4.3 之后,一切正常,除了
当 npm start ("start": "react-scripts start"
) 时,路径将变为 http://localhost:3000/temp_project/resources
这不是预期的。 (预计有 http://localhost:3000/ )
Hot fix = 每次手动更改路径到 http://localhost:3000/
如果我将 "homepage": "/temp_project/resources"
更改为 "homepage": "/"
,那么我的 http://localhost:8080/temp_project(索引页)将变为空白页。我的 npm start ("start": "react-scripts start"
) 工作正常。
我该怎么办??对不起,如果这是一个愚蠢的问题。谢谢。
补充:
这是一个 Maven spring 引导项目,使用 eirslett/frontend-maven-plugin 和 maven-resources-plugin
package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8080",
"homepage": "/temp_project/resources",
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
你能试试 "homepage": "."
或者 "homepage": "./"
吗...如果有帮助请告诉我