This commit is contained in:
@@ -24,6 +24,17 @@ pnpm type-check
|
||||
pnpm build:h5
|
||||
```
|
||||
|
||||
生产构建必须通过部署环境变量注入真实腾讯地图 Web Key,Key 不提交到仓库:
|
||||
|
||||
```powershell
|
||||
$env:VITE_TENCENT_MAP_KEY = '<真实腾讯地图 Web Key>'
|
||||
pnpm build:h5
|
||||
Remove-Item Env:VITE_TENCENT_MAP_KEY
|
||||
```
|
||||
|
||||
构建脚本会拒绝 Key 占位符、历史测试域名和旧 MinIO 地址;测试构建可使用
|
||||
`pnpm build:test:h5`,该命令只允许保留地图 Key 占位符,不允许旧域名进入产物。
|
||||
|
||||
`pnpm build:h5` 会先执行 `uni build -p h5`,再执行 `scripts/copy-h5-nav-assets.cjs`,把 `static/nav-assets` 复制到 `dist/build/h5/static/nav-assets`。
|
||||
|
||||
构建后重点检查:
|
||||
@@ -95,6 +106,39 @@ location ^~ /static/nav-assets/ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Vite 产物文件名带内容 hash,可以长时间缓存且不会污染新版本。
|
||||
location ^~ /assets/ {
|
||||
expires 365d;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# SDK、Engine、讲解图片和音频使用带版本/日期的路径,缓存 30 天。
|
||||
location = /engine/index.html {
|
||||
expires -1;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location ^~ /engine/ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, max-age=2592000";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location ^~ /static/ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, max-age=2592000";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# HTML 负责指向最新 hash 资源,必须及时重新验证。
|
||||
location = /index.html {
|
||||
expires -1;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user