Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Sass Installation

Sass Installation

In this section we mainly introduce the installation and usage of Sass.

NPM Installation

We can use npm (NPM usage introduction) to install Sass.

npm install -g sass

**Note:** For npm in China, it is recommended to use the Taobao mirror for installation. Reference:Solving the Slow npm Issue in China

Installation on Windows

We can use Windows' package manager Chocolatey to install:

choco install sass

Mac OS X (Homebrew) Installation

Mac OS can use Homebrew package manager to install:

brew install sass/sass/sass

For more installation methods, see the official website:https://sass-lang.com/install


Usage Introduction

Our tutorial uses the npm-installed sass; after installation you can check the version:

$ sass --version 1.22.12 compiled with dart2js 2.5.0 Next we create a runoob-test.scss file with the following content:

runoob-test.scss file code:

/* Define variables and values */

$bgcolor

:

lightblue

;

$textcolor

:

darkblue

;

$fontsize

:

18px

;

/* Use variables */

body

{

 

background-color

:

$bgcolor

;

 

color

:

$textcolor

;

 

font-size

:

$fontsize

;

}

Then enter the following command in the command line to convert the .scss file into css code:

$ sass runoob-test.scss 

@charset "UTF-8";

/* Define variables and values */

/* Using variables */

body {

  background-color: lightblue;

  color: darkblue;

  font-size: 18px;

}

We can append a .css file name afterward to save the code to a file:

$ sass runoob-test.scss runoob-test.css

This will generate a runoob-test.css file in the current directory, with the code as follows:

@charset "UTF-8";

/* Define variables and values */

/* Using variables */

body {

  background-color: lightblue;

  color: darkblue;

  font-size: 18px;

}



/*# sourceMappingURL=runoob-test.css.map */