Languages
[Edit]
EN

VS Code - create SCSS / SASS project with Live Sass Compiler

0 points
Created by:
Rogan-Wilkes
727

In this article, we would like to show you how to create project with Live Sass Compiler for HTML web page.

1. Create project

Create project with the following structure:

/project_directory/
 ├─ index.html
 └─ style.scss

Example file content

index.html

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div>Hello World!</div>
</body>
</html>

style.scss

$bg-main-color: yellow;

body {
    background: $bg-main-color;
}

2. Install sass

Open Terminal in your project and install sass globally:

npm install -g sass

Or use the following article to install Sass locally: SCSS / SASS - local installation 

Note:

If you are looking another way to install sass, go the the following page: Sass: Install Sass.

3. Install Live Sass Compiler

Go to the Extensions tab (Ctrl + Shift + X), search and install Live Sass Compiler

VS Code - install Live Sass Compiler
VS Code - install Live Sass Compiler

4. VS Code - Run Live Sass Compiler

Once the Live Sass Compiler installation is complete, you will be able to run it using Watch Sass button from the bar at the bottom of the VS Code. This will compile all the .scss files into the .css files that you can later use in your project (as we did in <link> element in the HTML template above - href="style.css").

VS Code - Run Live Sass Compiler
VS Code - Run Live Sass Compiler

5. Result

Now, we can see that the variable from style.scss file has been successfully compiled into style.css file:

body {
  background: yellow;
}

and when you open the index.html file, you will see the following result:

HTML web page with Live Sass Compiler example
HTML web page with Live Sass Compiler example

 

See also

  1. SCSS / SASS - local installation

References

  1. Sass: Install Sass

Alternative titles

  1. HTML - create project with Live Sass Compiler (VS Code)
  2. HTML - web page with Live Sass Compiler example
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join