fix: 修复本地黑金主题资源发布

This commit is contained in:
WuYongJie 2026-07-22 15:24:44 +08:00
parent 664e2999aa
commit 9e2c1a2ab7
2 changed files with 32 additions and 5 deletions

6
public/css/app.css vendored

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,8 @@ param(
[ValidateRange(1024, 8192)]
[int]$MaxOldSpaceSizeMB = 4096,
[ValidateRange(1, 8)]
[int]$TerserWorkers = 2
[int]$TerserWorkers = 2,
[switch]$PublishLocal
)
$ErrorActionPreference = 'Stop'
@ -102,6 +103,26 @@ function Write-Utf8NoBom {
[IO.File]::WriteAllText($Path, $Value, [Text.UTF8Encoding]::new($false))
}
function Publish-FrontendCache {
$cachedJsPath = Join-Path $frontendOutputRoot 'js'
$cachedCssPath = Join-Path $frontendOutputRoot 'css/app.css'
$cachedManifestPath = Join-Path $frontendOutputRoot 'mix-manifest.json'
foreach ($requiredPath in @($cachedJsPath, $cachedCssPath, $cachedManifestPath)) {
if (-not (Test-Path -LiteralPath $requiredPath)) {
throw "Frontend cache output is missing: $requiredPath"
}
}
if (Test-Path -LiteralPath $publicJsPath) {
Remove-Item -LiteralPath $publicJsPath -Recurse -Force
}
Copy-Item -LiteralPath $cachedJsPath -Destination $publicJsPath -Recurse
Copy-Item -LiteralPath $cachedCssPath -Destination $trackedCssPath -Force
Copy-Item -LiteralPath $cachedManifestPath -Destination $publicManifestPath -Force
}
$packageLockHash = Get-PathFingerprint @('package-lock.json')
$jsFingerprintInputs = @(
'resources/assets/js',
@ -144,6 +165,12 @@ $cssCacheValid = Test-CacheFingerprint `
if ($jsCacheValid -and $cssCacheValid) {
Write-Host 'Frontend inputs unchanged. Reusing JavaScript, CSS, and dependency caches.'
if ($PublishLocal) {
Publish-FrontendCache
Write-Host 'Published cached frontend assets to the local public directory.'
}
return
}
@ -281,7 +308,7 @@ finally {
$env:NODE_OPTIONS = $originalNodeOptions
$env:CAIWU_BUILD_TARGET = $originalBuildTarget
$env:CAIWU_TERSER_WORKERS = $originalTerserWorkers
if ($null -ne $trackedCssBackup) {
if (-not $PublishLocal -and $null -ne $trackedCssBackup) {
[IO.File]::WriteAllBytes($trackedCssPath, $trackedCssBackup)
}
}