Sometimes I am amazed that documentation for something as ubiquitous as SASS is hard to find. There is plenty of stuff about how to write sass itself, but actually using the scripts, specifically the command-line and it basically mentions that you can use the normal sass options, doesn't explain how, and none of the examples seem to show much more than just input file:output file!

Specifically, I wanted to alter the compression being used and it was not clear how to pass this to the Windows batch file that Dart uses to call sass. Is it --option:something --option=something --option something?

I tried a few variations and got errors like "Positional and ":" arguments may not both be used" and "Only two positional args may be passed".

Answer: You need to use

sass.bat --flag --otherflag inputfile.scss output.css --parameter value --otherparameter value

I eventually worked this out using a trick that I had read somewhere about how to get Netbeans to call the sass file correctly. The problem is that Netbeans assumes the arguments to pass to sass and it includes --debug-info and --cache-location which do not match Dart sass. Whether they match another flavour or are just out of date, I don't know: the options should have underscores (and neither are actually needed anyway).

The trick was to edit the sass.bat file provided in the Dart sass windows command line utility and do some batch magic to alter the command line before sass sees it.

Netbeans calls it like this (newlines added for clarity):

"C:\path\to\sass.bat" 
"--cache-location" "C:\Blah\Cache\8.2\sass-compiler" 
"--debug-info" 
"C:\Blah\site.scss" 
"C:\Blah\site.css"

Inside the batch file, lines 3, 4 and 5 remove the unecessary parts from the arguments by using a batch replacement function:

SET ARG=%ARG:X=Y%

i.e. take arguments and replace X with Y. In the first instance, X is "--cache-location " and Y is nothing (the part after the equals and before the % closing tag):

set SCRIPTPATH=%~dp0
set arguments=%*
set arguments=%arguments:--cache-location =%
set arguments=%arguments:C:\Blah\Cache\8.2\sass-compiler =%
set arguments=%arguments:--debug-info =%


The next lines add the style option after the input and output files and then runs sass using dart and passing the full arguments to it:

set arguments=%arguments% --style compressed
 "%SCRIPTPATH%\src\dart.exe" --no-preview-dart-2 "-Dversion=1.13.4" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments%