How can I use the Sass CSS preprocessor in Visual Studio 2013? Are there any extensions that provide support for Sass?
相关问题
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
- Visual Studio 2019 - error MSB8020: The build tool
- 'System.Threading.ThreadAbortException' in
- Custom controls disabled. There was an internal is
相关文章
- How to show location of errors, references to memb
- How to track MongoDB requests from a console appli
- Web Test recorder does not allow me to record a te
- Visual Studio Hangs on Loading UI Library
- How to use Mercurial from Visual Studio 2010?
- The program '[4432] iisexpress.exe' has ex
- Copy different file to output directory for releas
- How to disable CodeLens' references display in
In Visual Studio 2013 SP 4 there is no problem adding a SCSS file and syncing on every save. I got confused when syncing failed, I found the problem was using a variable before it was defined. The SCSS file doesn't show any error but sync fails.
This works for sync:
This doesn't work for sync
In the second case there are no errors and intellisense works, but sync fails.
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:
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
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
for ASP.NET there is a couple of ways to do integrate with SASS. Chripy is a common plug-in this is something you want to install in visual studio as an extension.
and thus design time compilation , you can find out more about chripy in http://chirpy.codeplex.com/ ,
as well as there is another package you can install via Nuget :
For anyone else looking for an answer to this, I'm posting to save you time as some of the answers are a little out of date.
Whilst working on a small web project in Visual Studio 2013, I wanted to use SASS for the first time. I did some digging and discovered VS 2013 Update 2 was released with native support for SASS (
.scss
) files.After a bit more digging, and with no experience of using SASS, I installed Web Essentials 2013 for Update 2 that is used to compile and generate the corresponding
.css
files.Even still, I wasn't clear on how it all tied together, but this blog post did a great job of explaining everything for a first timer.
Snippets From Blog (Credit to @akatakritos)
.scss
).scss
file to your project, e.g.styles.scss
styles.scss
, save, and it will auto generate astyles.css
file under the.scss
file.css
fileUPDATE July 2015:
In a later Web Essentials update, namely: Version 2.5 for Update 4 Nov 12. 2014, the SASS compiler has been removed.
Alternate compilers:
If you have
MVC 6
, you could just usegulp
. Original source here: http://developer.telerik.com/featured/css-preprocessing-with-visual-studio/Add the
NPM
dependencies inpackage.json
:Then in
gulpfile.js
:Finally, in the
Task Runner Explorer
,right-click
on your new tasksass
thenBindings
then selectAfter Build
Last version of Visual Studio + last version of Web Essentials http://vswebessentials.com/download allows to use Sass and Less out of the box.