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容器-阿里云开发者社区

相关推荐
kyriewen5 小时前
React Hooks原理:为什么不能写在if里?揭开Hook的“魔法”面纱
前端·react.js·前端框架
十一.36610 小时前
012-014 对state的理解,初始化state,react中的事件绑定
前端·react.js·前端框架
谢尔登12 小时前
【Next】客户端组件和服务端组件
前端·javascript·react.js·架构
旷世奇才李先生13 小时前
React 18\+TypeScript实战: hooks封装与组件设计模式
react.js·设计模式·typescript
telllong13 小时前
深入理解React Fiber架构:从栈调和到时间切片
前端·react.js·架构
kyriewen1 天前
React性能优化:从“卡成狗”到“丝般顺滑”的5个秘诀
前端·react.js·性能优化
nunumaymax1 天前
【第三章-react 应用(基于 react 脚手架)】
前端·react.js·前端框架
倾颜1 天前
React 19 源码怎么读:createRoot 和 root.render 到底做了什么?
react.js
Z_Wonderful1 天前
微前端:Webpack 配置 vs Vite 配置 超清晰对比
前端·webpack·node.js