Sass: Syntactically Awesome Style Sheets is the most mature, stable, and powerful professional grade CSS extension language in the world.
1. Steps to use sass in Native html
-
Install
sassglobally by npmsudo npm install sass -g
-
Create separate folders to put
.scssand.cssfiles -
Watch
.scssfiles and compile them to.cssreal-time-
Monitor and sync compile single .scss file
sass --watch input.scss output.css
-
Monitor and sync compile
.scssfile to.cssin its own directorysass --watch from/scss:to/css
-
Or use an extention in VsCode to compile:
- live-sass-compiler: Compile Sass or Scss to CSS at realtime with live browser reload.
- easy-sass: Built-in, easy to use Sass compiler
-
-
Link the
.cssfile in the header of html document:<link rel="stylesheet" href="css/index.css" />
2. Steps to use sass in React
-
Install
node-sassas dependency for Reactnpm install node-sass -S
-
Change file extension
.cssto.scss -
Import the
.scssfiles in React component:import "components/Application.scss"
or read the React official tutorial here
3. Steps to use sass in Vue.js
-
Install npm packages as development dependency:
npm install node-sass sass-loader -D
or setup to use them when creating Vue app via
vue-cliscaffold tool. You can pick a preset manually and choose a CSS Preprocessor tool while running the vue-cli scalffold. If you chooseSASS/SCSS,node-sassandsass-loaderwill be installed automatically when the project is created.npm install -g vue-cli vue create appname Vue CLI v4.4.6 ? Please pick a preset: Manually select features ? Check the features needed for your project: Babel, CSS Pre-processors, Linter ? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with dart-sass) ❯ Sass/SCSS (with node-sass) Less Stylus
-
Add
lang="scss"in thestyletag of the Vue component:<style lang="scss"> /* SCSS code */ </style>

Comments