修复了线上问题
This commit is contained in:
1 parent
42ccb20fe6
commit
791210bb05
2 files changed
+12
-14
No files matched your search
+11
-13
@@ -110,13 +110,13 @@ if (Test-Path $DistDir) {
|
||||
Remove-Item -Recurse -Force $DistDir
|
||||
Write-Host " 已删除: $DistDir"
|
||||
}
|
||||
# 清理 TempLate/assets/GVSite 旧产物目录(构建产物统一收敛到该子目录)
|
||||
$ProdGvsiteDir = Join-Path $TemplateRoot 'assets\GVSite'
|
||||
# 清理 TempLate/GVSite 旧产物目录(构建产物统一收敛到该子目录)
|
||||
$ProdGvsiteDir = Join-Path $TemplateRoot 'GVSite'
|
||||
if (Test-Path $ProdGvsiteDir) {
|
||||
Get-ChildItem -Path $ProdGvsiteDir -Recurse -Force | Remove-Item -Recurse -Force
|
||||
Write-Host " 已清理旧产物目录: assets/GVSite/"
|
||||
Write-Host " 已清理旧产物目录: GVSite/"
|
||||
} else {
|
||||
Write-Host " assets/GVSite 目录不存在,跳过" -ForegroundColor DarkGray
|
||||
Write-Host " GVSite 目录不存在,跳过" -ForegroundColor DarkGray
|
||||
}
|
||||
Write-Host ''
|
||||
|
||||
@@ -141,8 +141,8 @@ Write-Host ''
|
||||
# =====================
|
||||
Write-Host '[4/6] 同步产物到 www 生产目录...' -ForegroundColor Yellow
|
||||
|
||||
# 复制 GVSite 构建产物到生产目录 assets/GVSite/(vite assetsDir=GVSite,产物位于 dist/GVSite/)
|
||||
$ProdGvsite = Join-Path $TemplateRoot 'assets\GVSite'
|
||||
# 复制 GVSite 构建产物到生产目录 GVSite/(vite assetsDir=GVSite,产物位于 dist/GVSite/,相对引用 GVSite/...)
|
||||
$ProdGvsite = Join-Path $TemplateRoot 'GVSite'
|
||||
$DistGvsite = Join-Path $DistDir 'GVSite'
|
||||
if (Test-Path $DistGvsite) {
|
||||
if (-not (Test-Path $ProdGvsite)) {
|
||||
@@ -151,19 +151,17 @@ if (Test-Path $DistGvsite) {
|
||||
# 先清空旧产物,避免 hash 文件堆积
|
||||
Get-ChildItem -Path $ProdGvsite -File -ErrorAction SilentlyContinue | Remove-Item -Force
|
||||
Copy-Item -Recurse -Force (Join-Path $DistGvsite '*') $ProdGvsite
|
||||
Write-Host " 已同步: assets/GVSite/"
|
||||
Write-Host " 已同步: GVSite/"
|
||||
} else {
|
||||
Write-Warning " dist 中未找到 assets/GVSite,请检查 vite.config.ts 的 base 配置"
|
||||
Write-Warning " dist 中未找到 GVSite,请检查 vite.config.ts 的 assetsDir 配置"
|
||||
}
|
||||
|
||||
# 复制 index.html(并把产物引用 /GVSite/ 改为实际部署位置 /assets/GVSite/)
|
||||
# 复制 index.html(产物引用为 /GVSite/...,与部署位置 GVSite/ 一致,无需改写)
|
||||
$DistIndex = Join-Path $DistDir 'index.html'
|
||||
$ProdIndex = Join-Path $TemplateRoot 'index.html'
|
||||
if (Test-Path $DistIndex) {
|
||||
$indexHtml = Get-Content $DistIndex -Raw
|
||||
$indexHtml = $indexHtml -replace '/GVSite/', '/assets/GVSite/'
|
||||
Set-Content -Path $ProdIndex -Value $indexHtml -Encoding UTF8 -NoNewline
|
||||
Write-Host " 已同步: index.html(引用已改写为 /assets/GVSite/)"
|
||||
Copy-Item -Force $DistIndex $ProdIndex
|
||||
Write-Host " 已同步: index.html"
|
||||
}
|
||||
|
||||
Write-Host ' 同步完成'
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ export default defineConfig({
|
||||
outDir: 'dist',
|
||||
sourcemap: false,
|
||||
chunkSizeWarningLimit: 1500,
|
||||
// 构建产物收敛到 dist/GVSite/*,部署时同步到 TempLate/assets/GVSite
|
||||
// 构建产物收敛到 dist/GVSite/*(相对引用 GVSite/...),部署时同步到 TempLate/GVSite/
|
||||
assetsDir: 'GVSite',
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user