O'Reilly logo

Mastering Sass by Luke Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Node.js, node-sass, and fileWatch

Using npm to run shell commands is all well and good, but as you can imagine it has its limits. When you want to really complicate things, you'll need to start writing tasks in Node.js. To do this we'll need that index.js file we specified in our package.json entry point field.

Create a file called index.js. Next we'll need to download a package which compiles watches our Sass files. The package is node-sass. The node-sass is a Node "wrapper" of the LibSass port of Sass. This means we write code familiar to Node which then uses LibSass to actually compile and do whatever else we ask.

So first we'll run the command to download and install node-sass into our project:

npm install node-sass --save-dev

This tells npm ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required