Skip to content

Latest commit

 

History

History
58 lines (35 loc) · 1.6 KB

README.md

File metadata and controls

58 lines (35 loc) · 1.6 KB

Using node-sass with Hapi and watching with scripts

An example app using the node-sass npm module to compile .scss to CSS. I am using Hapi to create a simple server serving a static file, but the approach below will work with other frameworks or indeed no frameworks.

SASS?

http://sass-lang.com/guide

Dependencies

node and npm

nodemon

npm install -g nodemon

node-sass

npm install node-sass

The scripts

In the scripts section of package.json:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "build-css": "node-sass --include-path scss sass/main.scss public/css/main.css",
  "watch-css": "nodemon -e scss -x \"npm run build-css\"",
  "devstart": "nodemon server.js"
}

build-css: Uses node-sass to compile .scss to css (in specified paths).

watch-css: Uses nodemon to watch for changes to scss files and run build-css when changes are made.

devstart: Starts the server, watching for changes and restarting the server when changes are made.

How to use

Clone this repo

clone this repo

git clone https://github.com/mantagen/node-sass-example

Then npm install

npm install

Then run

In one terminal: npm run watch-css

In another terminal: npm run devstart