I picked node-sass implementer for libsass because it is based on node.js.

Installing node-sass

  • (Prerequisite) If you don't have npm, install Node.js first.
  • $ npm install -g node-sass installs node-sass globally -g.

This will hopefully install all you need, if not read libsass at the bottom.

How to use node-sass from Command line and npm scripts

General format:

$ node-sass [options] <input.scss> [output.css]
$ cat <input.scss> | node-sass > output.css

Examples:

  1. $ node-sass my-styles.scss my-styles.css compiles a single file manually.
  2. $ node-sass my-sass-folder/ -o my-css-folder/ compiles all the files in a folder manually.
  3. $ node-sass -w sass/ -o css/ compiles all the files in a folder automatically whenever the source file(s) are modified. -w adds a watch for changes to the file(s).

More usefull options like 'compression' @ here. Command line is good for a quick solution, however, you can use task runners like Grunt.js or Gulp.js to automate the build process.

You can also add the above examples to npm scripts. To properly use npm scripts as an alternative to gulp read this comprehensive article @ css-tricks.com especially read about grouping tasks.

  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • Add "sass": "node-sass -w sass/ -o css/" to scripts in package.json file. It should look something like this:
"scripts": {
    "test" : "bla bla bla",
    "sass": "node-sass -w sass/ -o css/"
 }
  • $ npm run sass will compile your files.

How to use with gulp

  • $ npm install -g gulp installs Gulp globally.
  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • $ npm install --save-dev gulp installs Gulp locally. --save-dev adds gulp to devDependencies in package.json.
  • $ npm install gulp-sass --save-dev installs gulp-sass locally.
  • Setup gulp for your project by creating a gulpfile.js file in your project root folder with this content:
'use strict';
var gulp = require('gulp');

A basic example to transpile

Add this code to your gulpfile.js:

var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
  gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

$ gulp sass runs the above task which compiles .scss file(s) in the sass folder and generates .css file(s) in the css folder.

To make life easier, let's add a watch so we don't have to compile it manually. Add this code to your gulpfile.js:

gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

All is set now! Just run the watch task:

$ gulp sass:watch

How to use with Node.js

As the name of node-sass implies, you can write your own node.js scripts for transpiling. If you are curious, check out node-sass project page.

What about libsass?

Libsass is a library that needs to be built by an implementer such as sassC or in our case node-sass. Node-sass contains a built version of libsass which it uses by default. If the build file doesn't work on your machine, it tries to build libsass for your machine. This process requires Python 2.7.x (3.x doesn't work as of today). In addition:

LibSass requires GCC 4.6+ or Clang/LLVM. If your OS is older, this version may not compile. On Windows, you need MinGW with GCC 4.6+ or VS 2013 Update 4+. It is also possible to build LibSass with Clang/LLVM on Windows.

Answer from Thoran on Stack Overflow
Top answer
1 of 4
268

I picked node-sass implementer for libsass because it is based on node.js.

Installing node-sass

  • (Prerequisite) If you don't have npm, install Node.js first.
  • $ npm install -g node-sass installs node-sass globally -g.

This will hopefully install all you need, if not read libsass at the bottom.

How to use node-sass from Command line and npm scripts

General format:

$ node-sass [options] <input.scss> [output.css]
$ cat <input.scss> | node-sass > output.css

Examples:

  1. $ node-sass my-styles.scss my-styles.css compiles a single file manually.
  2. $ node-sass my-sass-folder/ -o my-css-folder/ compiles all the files in a folder manually.
  3. $ node-sass -w sass/ -o css/ compiles all the files in a folder automatically whenever the source file(s) are modified. -w adds a watch for changes to the file(s).

More usefull options like 'compression' @ here. Command line is good for a quick solution, however, you can use task runners like Grunt.js or Gulp.js to automate the build process.

You can also add the above examples to npm scripts. To properly use npm scripts as an alternative to gulp read this comprehensive article @ css-tricks.com especially read about grouping tasks.

  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • Add "sass": "node-sass -w sass/ -o css/" to scripts in package.json file. It should look something like this:
"scripts": {
    "test" : "bla bla bla",
    "sass": "node-sass -w sass/ -o css/"
 }
  • $ npm run sass will compile your files.

How to use with gulp

  • $ npm install -g gulp installs Gulp globally.
  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • $ npm install --save-dev gulp installs Gulp locally. --save-dev adds gulp to devDependencies in package.json.
  • $ npm install gulp-sass --save-dev installs gulp-sass locally.
  • Setup gulp for your project by creating a gulpfile.js file in your project root folder with this content:
'use strict';
var gulp = require('gulp');

A basic example to transpile

Add this code to your gulpfile.js:

var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
  gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

$ gulp sass runs the above task which compiles .scss file(s) in the sass folder and generates .css file(s) in the css folder.

To make life easier, let's add a watch so we don't have to compile it manually. Add this code to your gulpfile.js:

gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

All is set now! Just run the watch task:

$ gulp sass:watch

How to use with Node.js

As the name of node-sass implies, you can write your own node.js scripts for transpiling. If you are curious, check out node-sass project page.

What about libsass?

Libsass is a library that needs to be built by an implementer such as sassC or in our case node-sass. Node-sass contains a built version of libsass which it uses by default. If the build file doesn't work on your machine, it tries to build libsass for your machine. This process requires Python 2.7.x (3.x doesn't work as of today). In addition:

LibSass requires GCC 4.6+ or Clang/LLVM. If your OS is older, this version may not compile. On Windows, you need MinGW with GCC 4.6+ or VS 2013 Update 4+. It is also possible to build LibSass with Clang/LLVM on Windows.

2 of 4
8

npx node-sass input.scss out.css

🌐
Sass
sass-lang.com › install
Sass: Install Sass
When you install Sass on the command line, you’ll be able to run the sass executable to compile .sass and .scss files to .css files.
🌐
GitHub
github.com › dhunanyan › scss-to-css-converter-npm-package
GitHub - dhunanyan/scss-to-css-converter-npm-package: The server part of the SCSS-to-CSS converter, providing a backend API for compiling SCSS code into CSS, using ANTLR for efficient parsing and transformation.
Welcome to the SCSS to CSS Converter NPM Package! This project is an NPM package designed to make converting SCSS (Sassy CSS) code to CSS (Cascading Style Sheets) simple and accessible.
Author   dhunanyan
🌐
GitHub
github.com › adamlui › scss-to-css
GitHub - adamlui/scss-to-css: { } Recursively compile all SCSS files into minified CSS.
{ "scripts": { "build:css": "scss-to-css [options]" } } Then run: npm run build:css · Current directory (outputs to css/): scss-to-css · Specific directory: scss-to-css path/to/your/directory · Specific file: scss-to-css path/to/your/file.scss ...
Author   adamlui
🌐
GitHub
github.com › Firebrand › css-to-scss
GitHub - Firebrand/css-to-scss: Will tidy your sass and scss
Convert plain CSS into SCSS, tidy up your existing SCSS, and more! npm install -g css-to-scss · npm install --save css-to-scss · You can use the command css-to-scss on a css file to convert it to scss, or on an existing scss file to clean ...
Starred by 11 users
Forked by 3 users
Languages   JavaScript 58.5% | CSS 41.5% | JavaScript 58.5% | CSS 41.5%
🌐
GitHub
github.com › jxnblk › css-scss
GitHub - jxnblk/css-scss: Convert CSS syntax to SCSS with calc, variables, and custom media queries
Convert CSS syntax to SCSS with calc, variables, and custom media queries · As used in http://basscss.com · npm install css-scss ·
Starred by 45 users
Forked by 6 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
npm
npmjs.com › package › css-scss
css-scss - npm
npm i css-scss · github.com/jxnblk/css-scss · github.com/jxnblk/css-scss · 303 · 0.1.1 · MIT · 8 years ago · johno · jxnblk · Try on RunKit ·
      » npm install css-scss
    
Published   Dec 13, 2017
Version   0.1.1
Author   Brent Jackson
🌐
GitHub
github.com › MonikaPalica › scss-to-css
GitHub - MonikaPalica/scss-to-css: Compile SCSS to CSS using the sass command.
Compile SCSS to CSS using the sass command. Install SASS. Start by installing SASS on your Mac if you haven't already. Open your terminal and run the following command: gem install sass · brew install sass/sass/sass · npm install -g sass ·
Author   MonikaPalica
Find elsewhere
🌐
npm
npmjs.com › package › css-to-scss
css-to-scss - npm
If you experience any bugs or issues please post a comment here: https://github.com/Firebrand/css-to-scss/issues Typically it will get responded to and resolved within 24hrs. Make sure to include the error message as well as the css you are inputting into it. ISC · css · scss · preprocessor · sass · converter · npm i css-to-scss ·
      » npm install css-to-scss
    
Published   Jul 12, 2018
Version   0.5.1
Author   Alex Tsirozidis
🌐
npm
npmjs.com › package › @dhunanyan › scss-to-css-converter
@dhunanyan/scss-to-css-converter - npm
git clone https://github.com/dhunanyan/scss-to-css-converter-npm-package.git
      » npm install @dhunanyan/scss-to-css-converter
    
🌐
GitHub
github.com › sass › node-sass
GitHub - sass/node-sass: :rainbow: Node.js bindings to libsass · GitHub
It allows you to natively compile .scss files to css at incredible speed and automatically via a connect middleware. Find it on npm: https://www.npmjs.com/package/node-sass
Starred by 8.5K users
Forked by 1.3K users
Languages   C++ 82.0% | JavaScript 12.6% | C 2.0% | Shell 1.8% | M4 0.6% | Makefile 0.5%
🌐
GitHub
github.com › lennym › npm-sass
GitHub - lennym/npm-sass: sass compilation with npm aware include paths
This module will automatically allow access to all locally installed npm modules, irrespective of their install location. ... var gulp = require('gulp'); var sass = require('gulp-sass'); gulp.task('sass', function () { gulp.src(['./src/*.scss']) .pipe(sass({ importer: require('npm-sass').importer })) .pipe(gulp.dest('./src/generated/css')); });
Starred by 13 users
Forked by 5 users
Languages   JavaScript 97.3% | SCSS 2.7% | JavaScript 97.3% | SCSS 2.7%
🌐
npm
npmjs.com › package › compile-sass
compile-sass - npm
To enable compilation and saving of SASS files to CSS files on all other environments when, for example, the application starts or with an npm script ... This is the documentation for v2. If you need the documentation for v1, please see the Readme from the last release of v1: https://github.com/eiskalteschatten/compile-sass/tree/v1.1.3
      » npm install compile-sass
    
Published   Oct 21, 2022
Version   2.0.0
Author   Alex Seifert
🌐
npm
npmjs.com › package › node-sass
node-sass - npm
New node release require minor ... GitHub Actions). We will open a single issue for interested parties to subscribe to, and close additional issues. Below is a quick guide for minimum and maximum supported versions of node-sass: Node-sass is a library that provides binding for Node.js to LibSass, the C version of the popular stylesheet preprocessor, Sass. It allows you to natively compile .scss files to css at incredible ...
      » npm install node-sass
    
Published   May 20, 2023
Version   9.0.0
Author   Andrew Nesbitt
🌐
Medium
medium.com › @brianhan › watch-compile-your-sass-with-npm-9ba2b878415b
Watch & Compile your Sass with npm. | by Brian Han | Medium
May 22, 2017 - I wrote a better way of using using node-sass with npm that addresses a lot of the comments I’ve received from y’all. You can find this tutorial (with source code) on my GitHub: Using node-sass ... Check it out, and feel free to send a PR or open an issue if you see any other problems.
🌐
GitHub
github.com › maximedaraize › create-scss
GitHub - maximedaraize/create-scss: ⚠️ scss starter, available as a npm package. Include directory structure, depedencies and script to ease your development process
"scripts": { "dev": "sass scss/main.scss css/style.css --watch --no-source-map", "compile": "sass scss/main.scss css/style.css --no-source-map", "minify": "sass scss/main.scss css/style.css --style=compressed --no-source-map", "add-prefixes": "postcss css/style.css -o css/style.css --use autoprefixer -b 'last 4 versions' --no-source-map", "production": "npm-run-all cs-compile cs-compress cs-prefix" }, Adapt responsive helper to match new breakpoints strategy
Starred by 7 users
Forked by 2 users
Languages   SCSS 86.0% | JavaScript 14.0% | SCSS 86.0% | JavaScript 14.0%
🌐
npm
npmjs.com › package › scss-compile
scss-compile - npm
Just edit the assets/css path in the package.json file. scss · sass · css · compiler · npm i scss-compile · github.com/tylerreckart/sass-compile · github.com/tylerreckart/sass-compile#readme · 1,990 · 0.1.7 ·
      » npm install scss-compile
    
Published   Sep 03, 2015
Version   0.1.7
Author   Tyler A. Reckart
🌐
Codeconcisely
codeconcisely.com › posts › compile-scss-to-css
Compiling SCSS to CSS - Code Concisely
November 23, 2022 - Now, install the following packages that Webpack uses to compile SCSS to CSS. npm i --save-dev css-loader mini-css-extract-plugin sass sass-loader
🌐
LinkedIn
linkedin.com › pulse › watch-compile-your-sass-npm-aleksandar-cvjetan
Watch & Compile your Sass with npm
March 30, 2020 - ... -D flag is another way of saying “write these node_modules into my package.json under devDependencies” (go look at your package.json) node-sass is that thing gulp-sass uses to compile your scss files to css files.
🌐
GitHub
github.com › sass › sass
GitHub - sass/sass: Sass makes CSS fun! · GitHub
If you use Node.js, you can also install Sass using npm by running ... However, please note that this will install the pure JavaScript implementation of Sass, which runs somewhat slower than the other options listed here. But it has the same interface, so it'll be easy to swap in another implementation later if you need a bit more speed! See the Sass website for more ways to install Sass. Once you have Sass installed, you can run the sass executable to compile .sass and .scss files to .css ...
Starred by 15.4K users
Forked by 2.2K users
Languages   TypeScript 96.2% | Shell 3.5% | JavaScript 0.3%