![install sass on visual studio code install sass on visual studio code](https://res.cloudinary.com/practicaldev/image/fetch/s--_590Jfjs--/c_imagga_scale,f_auto,fl_progressive,h_900,q_auto,w_1600/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66zi66k0hstd0qon3sb1.jpg)
![install sass on visual studio code install sass on visual studio code](https://i0.wp.com/kumardeepak.xyz/blog/wp-content/uploads/2021/05/stylelint-configured-vscode-npm.png)
scss files within the src/scss folder (including subfolders). Lets fix that now… add the following lines to the. Normally this works great, but since we’ve added custom build steps to compile the scss, FastBuild isn’t aware of this and doesn’t know to check the src/scss folder. That is because FastBuild will do prechecks to look for changes and if it doesn’t find any, it will skip the build process. If we run this now before adding fast build support we will see that it doesn’t actually build the scss when only the scss has changed.
![install sass on visual studio code install sass on visual studio code](https://bootstrapstudio.io/docs/img/guide/scss-editor.png)
The Microsoft Docs contains more information about the Target Element and Exec Task Element. Exec tells MSBuild to execute the specified command, in this case we are telling MSBuild to execute our npm script build-css. The BeforeTargets attribute tells MSBuild to run these tasks before running the PreBuildEvent.
#Install sass on visual studio code code
The Target element allows us to extend the build with additional tasks (in the code above the task is Exec which we will get to shortly). Now we have the npm script configured to build the src/scss folder we need to tell visual studio (or MSBuild more specifically) to run the command before building the project. The build-css script executes node-sass while telling it to look in the src/scss folder for any missing files ( -include-path src/scss), that we want the output to be compressed ( -output-style compressed), the file to process ( src/scss/site.scss this could be changed to the whole directory or specific files using glob patterns) and finally the output location ( -output wwwroot/css). The scripts section defines commands the can be executed by calling npm run script-name. "build-css": "node-sass -include-path src/scss -output-style compressed src/scss/site.scss -output wwwroot/css" "description": "This package does not do anything useful", Npm i node-sass -save-dev creates a dev dependency on the node-sass package which is what will be compiling the SCSS into CSS. Npm init creates an empty package.json for the project, which will later tell other machines the packages needed for this project to build. Open command prompt (note: PATH environment variable must contain npm directory for this to work).Ĭhange directory into the folder where the project is located. src folder structureĪdd the following content to the site.scss file. So we should have something that looks like this. For simplicity of this example, we are going to have one file (site.scss). Once it is has initialised, create a new folder in the root of the project called Scss. To get started, lets create the default MVC application.
![install sass on visual studio code install sass on visual studio code](https://i.stack.imgur.com/RQt0T.png)
#Install sass on visual studio code full
See the compiling SCSS at build time with visual studio GitHub repo for the full code base. That said this approach does rely on Node.JS to compile the SCSS but since Node.JS has wide spread adoption, the chances are current (or potential) team members will have it already. I believe the development environment should have as little dependencies as possible (including extensions). Firstly, there are extensions that can compile scss at build time… but every extension installed is another barrier to new team members coming onboard and getting up to speed on a project.