SASS is a CSS preprocessor that adds special features such as variables, loops, and functions into regular CSS. You can use SASS to write CSS. The goal is to make the coding process simpler and more organized.
SASS has two versions: .sass and .scss. The main difference between these versions is the syntaxes. Once we have created our .sass or .scss files, we need to convert them into standard CSS.
This guide will show how to compile your SASS/SCSS to CSS in Visual Studio Code.
Step 1: Install Live SASS Compiler Extension
- Select the Extensions tab from the sidebar.
- Search for Live Sass Compiler in the search box.
- Click on the Install button.
Step 2: Open an existing project in VS Code
- From the “Explorers” tab in the sidebar, click on the Open Folder button.
- Open the folder from your preferred directory.
- Once the folder is opened, you’ll see all the source files.
- As you can see from the above image, I have set up a simple HTML file to style it using SASS.
Step 3: Create a SASS/SCSS file
- Inside the “Explorer” panel, click on the New File button.
- Enter any name and press Enter. Make sure to add .sass or .scss at the end of the filename.
- Now, write the SASS code to style your HTML file. For example, I am entering the following code:
.card { position: relative; background-color: red; .card__name { background-color: blueviolet; }
- Click on the Watch Sass button from the Status bar at the bottom of VS Code.
- Finally, the extension will generate a .css and map.css file inside the project folder. The following image shows our output.
As you may have noticed, the Live Sass Compiler extension compiles your SASS files in real time. Also, choosing SASS over directly writing CSS removes many syntax requirements, like blocks and semicolons. It makes it easy to execute CSS.
perfect
great plugin, working fine!
Thanx. This is resolve my problem.
hello I am using VS Code with extension Sass Live Compiler. When I change .scss file via Chome devtool, the file did change in VSCode,it is saved on disk with new data, I have set AUTO SAVE in VSCode, BUT extension Sass Live Compile dont compile it until I manualy save the .scss file. Can somebody help ? Thanks