diff --git a/.gitignore b/.gitignore index 8e1baa2..06a0459 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,6 @@ lerna-debug.log* node_modules .npm-cache -dist -dist-ssr *.local # Editor directories and files diff --git a/mac.conf b/font2svg.mac.conf similarity index 66% rename from mac.conf rename to font2svg.mac.conf index 17b9f0d..6da8861 100644 --- a/mac.conf +++ b/font2svg.mac.conf @@ -1,5 +1,7 @@ -# Font2SVG - Nginx 配置(mac.biboer.cn) -# 用途:为微信小程序提供静态字体资源 + 远端 SVG 渲染 API +# Font2SVG - Mac Nginx 配置(mac.biboer.cn / mac-tunnel.biboer.cn) +# 用途: +# 1) 为微信小程序提供字体清单、默认配置、路由配置与渲染 API +# 2) 提供 Web 应用静态页面(frontend/dist) server { listen 80; @@ -9,15 +11,15 @@ server { } # Cloudflare Tunnel 入口(推荐): -# 外部 https://mac-tunnel.biboer.cn(443) -> cloudflared -> 本机 80(直连本机服务) +# 外部 https://mac-tunnel.biboer.cn(443) -> cloudflared -> 本机 80(Nginx) server { listen 80; listen [::]:80; server_name mac-tunnel.biboer.cn; - # 静态资源根目录(包含 fonts/、fonts.json、miniprogram/assets/*) + # 项目根目录(包含 fonts/、fonts.json、miniprogram/assets/*、frontend/dist/*) root /Users/gavin/font2svg; - index fonts.json; + index index.html; access_log /opt/homebrew/var/log/nginx/access.log; error_log /opt/homebrew/var/log/nginx/error.log; @@ -66,7 +68,9 @@ server { proxy_set_header X-Forwarded-Proto $scheme; } - # 配置文件:短缓存,便于切换 + # -------------------- 小程序静态配置 -------------------- + + # 字体清单:短缓存,便于更新 location = /fonts.json { expires 1h; add_header Cache-Control "public, must-revalidate" always; @@ -98,9 +102,43 @@ server { try_files $uri =404; } - # 默认仅提供静态文件 + # -------------------- Web 静态应用(frontend/dist) -------------------- + + # Vite 构建产物目录:/assets/* + location ^~ /assets/ { + expires 30d; + add_header Cache-Control "public, immutable" always; + try_files /frontend/dist$uri =404; + } + + # 常见入口文件(精确匹配) + location = /index.html { + try_files /frontend/dist/index.html =404; + } + + location = /default.json { + try_files /frontend/dist/default.json =404; + } + + location = /favicon.ico { + try_files /frontend/dist/favicon.ico =404; + } + + location = /favicon.png { + try_files /frontend/dist/favicon.png =404; + } + + location = /favicon.svg { + try_files /frontend/dist/favicon.svg =404; + } + + location = /favicon_new.png { + try_files /frontend/dist/favicon_new.png =404; + } + + # Web SPA 路由回退(刷新任意前端路径时返回 index.html) location / { - try_files $uri =404; + try_files $uri $uri/ /frontend/dist/index.html; } # 禁止访问隐藏文件 @@ -109,4 +147,4 @@ server { access_log off; log_not_found off; } -} \ No newline at end of file +}