react native web RN webpack nginx 部署

# nginx配置
location /app {
    root   html;
    index  index.html;
    # url 切换时始终返回index.html
    try_files $uri /app/index.html;
}
# 图片样式缓存1年
location ~* /app.*\.(js|css|png|jpg)$
{
    access_log off;
    expires    365d;
}
# html/xml/json 文件不缓存
location ~* /app.*\.(?:manifest|appcache|html?|xml|json)$
{
    expires    -1;
}


// package.json
"homepage": "http://localhost/app",

// react-router路由配置
// 注意指定basename
<BrowserRouter basename='/app'>
</BrowserRouter>

参考

https://www.cnblogs.com/BrickDogs/p/15952532.html

真实环境部署我们的React到Nginx容器-阿里云开发者社区 

猜你喜欢

转载自blog.csdn.net/linzhiji/article/details/131967620