Compiling Sass With NPM

in Sass

In this tutorial we're going to look at how we can compile SASS using a NPM package.

The package that we're going to use to compile the SASS is called node-sass.

This is a node package that will bind node.js to LibSass this allows you to compile native scss files into CSS.

First we need to install the the node-sass into our project. You can do this by using the following command.

npm install node-sass

Now we'll be able to use npm to compile our scss files into CSS by using the command node-sass style.scss style.css. We can do this by creating a new command inside the package.json file.

{
  "devDependencies": {
    "node-sass": "^4.7.2"
  },

  "scripts": {
    "scss": "node-sass style.scss style.css"
  }
}

This gives us a new npm command of npm scss that will take the style.scss and convert it into style.css.

Subscribe To Newsletter

Get weekly updates to your email