Radian Radian -4 years ago 294
Sass (Sass) Question

How to use Sass in Visual Studio 2013

How can I use the Sass CSS preprocessor in Visual Studio 2013? Are there any extensions that provide support for Sass?

Answer Source

Visual Studio 2013 Update 2

Visual Studio 2013 Update 2 has native syntax support for both SCSS and LESS files. You can create SCSS or LESS files and see syntax highlighting and intellisense for these file types. It does not however provide a method of compilation.

Here's a link to the blog explaining about the new features:

We added LESS in VS2013 RTM, and we now have a SASS project item and editor. SASS editor features are comparable to LESS editor, include colorization, variable and Mixins IntelliSense, comment/uncomment, quick info, formatting, syntax validation, outlining, goto definition, color picker, tools option setting etc.

Please note: This update seems to support the newer SassyCSS syntax only. I've tried getting it to work with the older indented SASS syntax without any success.

Compilation

  • Web Essentials. This is a great tool which does all the 'grunt' work for you. Newer versions of Web Essentials are available for Visual Studio 2013 Update 3, 4 and 5.
  • Another free one that just handles compilation is CompileSASS this also works in VS2015.
  • Alternatively you could use MindScape's WebWorkbench, which is a great tool with lots of nice features. There is a free version which does just about enough to get by but there is also a paid version which is far more comprehensive (but in my opinion a little too expensive considering there is a better free alternative).

Visual Studio 2015

For those of you moving to Visual Studio 2015, unfortunately there is still no native support for SASS and LESS compilation. And unfortunately Web Essentials will no longer be supporting compilation either. The author of Web Essentials (Mads Kristensen) explains the reason for this decision here.

Here are a list of extensions that can handle compilation:

WebCompiler (FREE)

Mads Kristensen (the author of web essentials) has created a standalone compilation tool called Web Compiler. All you have to do is install it, then right click on any of the SASS files you want to compile and select Web Compiler > Compile File. From that point on it is watched and anytime it is saved, the file will be compiled.

Download Web Compiler

CompileSASS (FREE)

Similar to Web Compiler this is a standalone extension that was created to work in both VS2013 and VS2015 because compilation was removed from the popular Web Essentials extension. It's lightweight and does the job very well with great error reporting. Read the author's blog about the extension here.

Download Compile SASS

Web Workbench (FREE/PAID)

Mindscape's Web Workbench was my favourite extension for many years when compiling SASS but I have since moved away in favour of the free alternatives. Still, the Pro version is a powerful tool with many ways to customise the outputted files but it is also quite expensive ($39) considering there are free tools out there.

Download Web WorkBench


Visual Studio Code

Same deal as above really, it has native support for SASS and LESS through syntax highlighting and Intellisense but lacks compilation.

Any of the compilers outlined above will work but if you wanted to set up compilation manually here is a brilliant guide:

https://code.visualstudio.com/Docs/languages/css

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download