Skip to content

Commit 29f3b71

Browse files
committed
Update build.yml
1 parent 2fc27c9 commit 29f3b71

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

.github/workflows/build.yml

+24-4
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,39 @@ jobs:
3939
# Copy necessary files into the dist directory
4040
Copy-Item -Recurse -Path "temp/*" -Destination "dist" -Force
4141
42+
- name: Backup JS files before modifying
43+
run: |
44+
# Create a backup of the original JS files
45+
Copy-Item -Recurse -Path "dist\assets\*.js" -Destination "dist\assets\backup" -Force
46+
4247
- name: Update paths in HTML and JS files
4348
run: |
4449
# Update paths in HTML files
4550
Get-ChildItem dist\*.html | ForEach-Object {
46-
(Get-Content $_.FullName) `
51+
$filePath = $_.FullName
52+
$content = Get-Content $filePath
53+
$newContent = $content `
4754
-replace 'src="(/assets/)', 'src="./assets/' `
48-
-replace 'href="(/assets/)', 'href="./assets/' | Set-Content $_.FullName
55+
-replace 'href="(/assets/)', 'href="./assets/'
56+
Set-Content -Path $filePath -Value $newContent
57+
58+
# Log the changes for debugging
59+
if ($newContent -ne $content) {
60+
Write-Host "Updated asset paths in $filePath"
61+
}
4962
}
5063
5164
# Update paths in JS files inside the assets folder
5265
Get-ChildItem dist\assets\*.js | ForEach-Object {
53-
(Get-Content $_.FullName) `
54-
-replace '("/assets/)', '("./assets/' | Set-Content $_.FullName
66+
$filePath = $_.FullName
67+
$content = Get-Content $filePath
68+
$newContent = $content -replace '("/assets/)', '("./assets/'
69+
70+
# Log the changes for debugging
71+
if ($newContent -ne $content) {
72+
Write-Host "Updating asset paths in $filePath"
73+
}
74+
Set-Content -Path $filePath -Value $newContent
5575
}
5676
5777
- name: List files in the dist directory after copying

0 commit comments

Comments
 (0)