一、背景描述:
react打包出來的文件,想部署在 如 https://www.abc.com/webapp下,
本項目使用的是history:hash 模式,
如果使用的是history:browser ,可參考該大神的文章https://www.freesion.com/article/5887723973/
二、解決方法
1、修改/添加 配置
// package.json
"homepage":"."
2、在每一個index.html文件添加
# webapp 是你自己文件夾的名稱
<base href="/webapp/">
3、將打包後的文件丟到服務器
4、nginx添加配置,重啓
location /webapp/ {
index index.html index.htm;
}