npm install --save-dev node-sass nodemon
"build-css": "node-sass -o css css"
// Where the first 'css' is the destination directory for compiled output.
// Second 'css' is the source folder with sass/scss files
// -o is shorthand for --output
e.g. "build-css": "node-sass --output [destination-directory-for-output] [sass-source-file-directory]"
"watch-css": "nodemon -e sass -x \"npm run build-css\""
// Where the '-e sass' tells nodemon to monitor files with that extension. Shorthand for '--ext'
// (e.g. 'nodemon -e sass,scss' will watch both types of sass files and restart on changes)
// The '-x' (shorthand for '--exec') will execute the following script
Hello,
Thank you for the gist.
I'd suggest a little modification, that could save us the installation of
nodemon
.If I'm not misunderstanding what you are doing in the gist, I think that these two
npm scripts
:are equivalent to this one:
Basically,
node-sass
is shipped with the functionality to watch on changes onsass
files and output them incss
(the names of the directories can be whatever you want of course ;) so we don't need to installnodemon
to trigger the build on change.More info here.