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

相关推荐
Easonmax3 小时前
零基础入门 React Native 鸿蒙跨平台开发:7——双向滚动表格实现
react native·react.js·harmonyos
Easonmax3 小时前
零基础入门 React Native 鸿蒙跨平台开发:6——竖向滚动表格实现
react native·react.js·harmonyos
Easonmax5 小时前
零基础入门 React Native 鸿蒙跨平台开发:8——固定表头和列的复杂表格
react native·react.js·harmonyos
Easonmax13 小时前
零基础入门 React Native 鸿蒙跨平台开发:3——固定表头表格实现
react native·react.js·harmonyos
Easonmax15 小时前
零基础入门 React Native 鸿蒙跨平台开发:9——表格数据动态加载与分页
react native·react.js·harmonyos
Easonmax16 小时前
零基础入门 React Native 鸿蒙跨平台开发:5——横向滚动表格实现
react native·react.js·harmonyos
Easonmax16 小时前
零基础入门 React Native 鸿蒙跨平台开发:1——实现基础表格组件
react native·react.js·harmonyos
光影少年16 小时前
前端如何定位组件变化及性能问题
前端·javascript·react.js
不爱吃糖的程序媛17 小时前
React Native 0.77.1 适配鸿蒙(RN-OH)信息总览
react native·react.js·harmonyos
一个处女座的程序猿O(∩_∩)O17 小时前
Next.js 与 React 深度解析:为什么选择 Next.js?
开发语言·javascript·react.js