2

I am trying to set up an NPM script that will watch for changes to .scss files in multiple directories and compile them to separate directories.

This is my current set up:

  "scripts": {
    "watch": "npm run bcon-watch && npm run root-watch",
    "root-watch": "node-sass -wr --source-map true --output-style compact css/sass/ -o css/",
    "bcon-watch": "node-sass -wr --source-map true --output-style compact bcon/css/sass/ -o bcon/css/"
  },

However this only runs the first script and watches that directory (root-watch), is it possible to watch multiple folders this way? if not what should I look into to make this work?

Thanks!

Aaranihlus
  • 143
  • 2
  • 13

1 Answers1

0

Had the same problem and tried several solutions, but the only one working for me was this How can I run multiple npm scripts in parallel?

Use a package called concurrently.

npm i concurrently --save-dev

Then setup your npm run dev task as so:

"dev": "concurrently --kill-others \"npm run start-watch\" \"npm run wp-server\""
DeadApe
  • 416
  • 1
  • 3
  • 10
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/29954184) – Sangeerththan Balachandran Sep 29 '21 at 21:23