Last active
August 20, 2024 14:56
-
-
Save mawiseman/408c09a4d335c2ea8b3db936829bc042 to your computer and use it in GitHub Desktop.
Sitecore SXA regenerate optimised files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this script in Sitecore Powershell Extensions | |
# It will delete the minifed files from master and publish the deletions to web | |
# Next time the site is visited they should be re-generated (if they aren't check your settings http://bit.ly/2TfrcfC) | |
# TODO: When publishing, there might be a better way to target folders in the media library instead of the hardcoded list | |
$masterItems = Get-Item -Path master: -Query "/sitecore/media library//*[@@key='optimized-min']" | |
$webItems = Get-Item -Path web: -Query "/sitecore/media library//*[@@key='optimized-min']" | |
Write-Host "Master Items: $($masterItems.length)" | |
Write-Host "Web Items: $($webItems.length)" | |
# Set this to $true to run the actual delete and publish | |
if($false) { | |
Write-Host "" | |
Write-Host "Deleting optimized-min files" | |
$masterItems | Remove-Item | |
Write-Host "" | |
Write-Host "Publishing deleted items" | |
Publish-Item -Path "master:\media library\Base Themes" -Recurse -Language "en" -Target web | |
Publish-Item -Path "master:\media library\Extension Themes" -Recurse -Language "en" -Target web | |
Publish-Item -Path "master:\media library\Themes" -Recurse -Language "en" -Target web | |
Publish-Item -Path "master:\media library\Feature" -Recurse -Language "en" -Target web | |
Write-Host "" | |
Write-Host "Master Items: $($masterItems.length)" | |
Write-Host "Web Items: $($webItems.length)" | |
} | |
else { | |
Write-Host "Nothing done" | |
} | |
Write-Host "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment