Skip to content

Instantly share code, notes, and snippets.

@andrew-rayco
Last active November 27, 2025 14:31
Show Gist options
  • Select an option

  • Save andrew-rayco/0f94245718067affa0dc06f5ab3b998c to your computer and use it in GitHub Desktop.

Select an option

Save andrew-rayco/0f94245718067affa0dc06f5ab3b998c to your computer and use it in GitHub Desktop.
Watch CSS setup with node-sass and nodemon

Watch CSS setup with node-sass and nodemon

npm install --save-dev node-sass nodemon

Add the following scripts to package.json

Build CSS

"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

"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

@Scorpovi4
Copy link

Scorpovi4 commented Feb 18, 2021

That's working in terminal, but my express server doesn't start unfortunately with this comand -x \"npm run watch-scss\"

@glippi
Copy link

glippi commented Sep 4, 2021

Can you teach me how to use nodemon to build js.

I suggest you to have a look at vite: https://vitejs.dev.
It's a simple and yet very powerful tool to build your js project and also to work locally with all the things you would expect to have like auto reload on save etc.

@netsanetamanuel
Copy link

how can i reactivate nodemon, it is not working after while

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment