Tell me some ways how can you compile Sass to CSS

Experience Level: Junior
Tags: Sass

Answer

There are multiple different tools that you can use for compiling Sass to CSS.

Sassmeister

To play with Sass syntax you can use on-line Sass compilers, for example Sassmeister.

node-sass

For more serious work you will need a tool that will automatically watch your Sass files and if any of them changes, it will automatically convert them to CSS files.

One of such tools is for example node-sass.
In order to use it:

Install Node.js

Install npm (Node Package Manager)

Go to your project folder and if you don't have a file package.json, create it by running the following command from the command line:

npm init

Install node-sass by running the following command from the command line:

npm install node-sass

Create a custom script by adding the following text to the package.json:

"scripts": {
    "scss": "node-sass --watch scss -o css"
  }

Create a folder scss and put some file with extension .scss into it.

Run the scss script from the command line:

npm run scss

Angular CLI

If you are building Angular applications and are using Angular CLI, you don't need to think about Sass compilation at all as Angular CLI will compile it automatically for you.

Comments

No Comments Yet.
Be the first to tell us what you think.
Sass for beginners
Sass for beginners

Are you learning Sass ? Try our test we designed to help you progress faster.

Test yourself