-
-
Save jstangroome/474832 to your computer and use it in GitHub Desktop.
Export-Minified
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
#requires -Version 2 | |
[CmdletBinding()] | |
param ( | |
[parameter( | |
Mandatory=$true, | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$true | |
)] | |
[string[]] | |
$Path | |
) | |
begin { | |
$ErrorActionPreference = 'Stop' | |
Set-StrictMode -Version Latest | |
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName | |
$PSScriptRoot = Split-Path $PSScriptFilePath -Parent | |
# Load AjaxMin.dll | |
Add-Type -Path (Join-Path -Path $PSScriptRoot -ChildPath "AjaxMin.dll") | |
} | |
process { | |
$Path | ForEach-Object { | |
# Load input data | |
$InputData = Get-Content $_ | |
$Minifier = New-Object -TypeName Microsoft.Ajax.Utilities.Minifier | |
# Perform the minification | |
$OutputData = $Minifier.MinifyStyleSheet($InputData) | |
$Minifier.Errors | ForEach-Object { | |
Write-Error $_ | |
} | |
# Write the output data | |
$OutputPath = [System.IO.Path]::ChangeExtension($_, ".min" + [System.IO.Path]::GetExtension($_)) | |
Write-Verbose "Writing output to $OutputPath" | |
Set-Content $OutputPath $OutputData | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment