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
to download/install the node-sass
package from the npm
registry. The --save-dev
flag tells it to automatically add it to our package.json file for us as a development dependency. This means this package is only necessary while we develop our site,...