2

I want to run my app.js using "dev" : "nodemon app.js" and I have also added "node-sass": "node-sass public/sass/main.scss public/css/style.css -w"

My goal is to run live server using nodemon app.js only once. And compile sass to css everytime I edit my sass file and press ctrl + S without restarting my server.

I have tried it by adding "dev": " nodemon app.js && node-sass public/sass/main.scss public/css/style.css -w" .This command is running server successfully but its not compiling my sass to css whenever im trying Ctrl + s on sass file.

Ibad Shaikh
  • 2,704
  • 3
  • 15
  • 27

2 Answers2

2

Use both commands on seperate terminals. Click the plus sign to open the terminal in the same directory or use git bash. enter image description here

Ibad Shaikh
  • 2,704
  • 3
  • 15
  • 27
1

You can also make another script merging both commands in your package.json.

"scripts": {
  "dev":"nodemon app.js",
  "node-sass":"node-sass public/sass/main.scss public/css/style.css -w",
  "dev:sass":"npm-run-all --parallel node-sass dev" 
}

By executing dev:sass, you will run both commands in parallel (note the --parallel flag).

Note: You have to install the "npm-run-all" devDependency to make the script work.

DrGregoryHouse
  • 510
  • 5
  • 12