Powershell build - compiling SASS Powershell build - compiling SASS powershell powershell

Powershell build - compiling SASS


I think my lack of experience with Powershell/build scripts in general had me overthinking this. I took the following steps:

1) Installed Ruby for Windows from here: https://www.ruby-lang.org/en/documentation/installation/

2) Open Command Prompt -> entered gem install ruby

3) Opened PowerGUI Script Editor (already installed, but can be downloaded here: http://software.dell.com/products/powergui-freeware/)

4) Created a function to execute the following: sass -t compressed "path\sassInput.scss" "path\sassOutput.css"

And presto. I do want to have a way of doing this for each .scss file in the directory that is not a partial, but this is enough to get me started for now.

UPDATE:This is what I ended up with for a Powershell script: (note $dirpath is set to my project's root directory elsewhere)

$stylesheetPath = $dirpath + "App_Themes\"$files = Get-ChildItem $stylesheetPath -Filter *.scss for ($i=0; $i -lt $files.Count; $i++) {    $file = $files[$i]    $fileName = $file.BaseName    $filePath = $file.FullName    if (-not $fileName.StartsWith("_")) {        $newFilePath =  "$stylesheetPath$fileName.css"        sass -t compressed $filePath $newFilePath    }}


You need a SASS compiler and your mileage may vary. The original compiler is written in Ruby, so, if you want to use that, you have to install Ruby, the SASS gem and invoke sass from your Powershell script.Another option is to use a compatible compiler like SassC or C6 which do not need the Ruby runtime.


I had the same problem. U have this one because powershell have restricted executable policy. U can do next:0. Install node.js, npm, node-sass

  1. Run PowerShell as Administrator
  2. Chech policy with Get-ExecutionPolicyU will see Restricted
  3. See all policies Get-ExecutionPolicy -List
  4. Run Set-ExecutionPolicy -ExecutionPolicy Unrestricted
  5. Press "Y"

Use node-sass -w ./input.scss ./output.css

Also, U can read more here