in CSS

Compiling Sass With NPM

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.

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email