Skip to content

An example app using the node-sass npm module to compile .scss to CSS.

Notifications You must be signed in to change notification settings

mantagen/node-sass-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

An example app using the node-sass npm module to compile .scss to CSS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published