Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET sass/scss compilation at run-time and at compile-time?

I am searching for a solution for compiling my .scss files at run-time and at compile-time.

The reason I need both is that our designers work on Macs and prefer the ease of having their .scss files compiled dynamically at run-time (especially during a development phase). On the other hand, I need compile-time support to validate that the SCSS compiles successfully during my build process. My goal is to fail a build if the SCSS doesn't compile.

I have found several libraries available on NuGet, however, minor flaws in each of them are holding me back.

Is there a solution available for both of these scenarios?

Here's where my research has led me:

Run-time Support

  • BundleTransformer.SassAndScss via HttpHandler (works with Bourbon, albeit very slow)
  • Cassette.Sass (unable to compile Bourbon due to error)

Compile-time support:

  • Cassette.MSBuild (Does not appear to bundle SCSS files, only CSS)
  • Mindscape Web Workbench (Pro version apparently includes a command-line tool, however, documentation is very limited on the feature)
  • Others?
like image 597
Derek Hunziker Avatar asked May 16 '13 21:05

Derek Hunziker


2 Answers

The Pro edition of the Mindscape Web Workbench includes a command-line tool for compiling at runtime. Currently, only the nightly build is capable of compiling Bourbon and Neat (one of my requirements).

Here is my pre-build event which is working great at the moment:

"C:\Program Files (x86)\Mindscape\Web Workbench\Command Line\wwcmd.exe"
"$(ProjectDir)scss\style.scss" /o:../css /style:compressed

UPDATE:

We decided to simply call SASS from a pre-build event as opposed to using Web Workbench.

call sass -C "$(ProjectDir)assets\scss\main.scss" "$(ProjectDir)assets\css\compiled\main.css" --style compressed
like image 130
Derek Hunziker Avatar answered Sep 18 '22 10:09

Derek Hunziker


Check out SassAndCoffee. It's what Cassette is using and it embeds everything into a few assemblies.

Web Workbench on the other hand actually installs ruby and the sass gems to the file system in a very long folder path hidden beneath the current users directory, which is likely to be troublesome for a web application and with respect to security and permissions.

like image 35
TugboatCaptain Avatar answered Sep 22 '22 10:09

TugboatCaptain