我正在尝试解决类似的问题-部署env-cmd
的CRA gh-pages
。问题是当我从
"build": "react-scripts build",
到
"build:staging": "env-cmd -f .env.staging react-scripts build",
已部署版本的某些源代码路径错误。 例如-代替路径
https://surfer19.github.io/green-roofs/img/green-building-top.jpg
它
https://surfer19.github.io/img/green-building-top.jpg
我的env.staging
包含
REACT_APP_API_URL=http://surfer19.github.io/green-roofs/
在"homepage": "http://surfer19.github.io/green-roofs/"
中将其切换到package.json
时,它可以正常工作。
任何想法可能在哪里出现问题?