M-Zuber / npm-watch

run npm scripts when files change
MIT License
323 stars 38 forks source link

Not watching *html files with valid template #69

Closed adamborys closed 3 years ago

adamborys commented 4 years ago

I run npm-watch in whole project directory with pattern

  "watch": {
    "push": "*.{js,html}"
  },

It works only when saving *.js files

My file tree: └─ main.js └─ variables-dialog.html └─ variables-service.js └─ package.json └─ package-lock.json

fabienlege commented 3 years ago

same problem for me : run npm-watch with this config not working

{
"watch": {
    "build": "src/*.jsx"
  },
  "scripts": {
    "start": "node ./scripts/start-non-split.js",
    "build": "node ./scripts/build-non-split.js",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "watch": "npm-watch"
  }
}

It's run build a first time on launch but never re-run build script when saving jsx file...

EDIT : Watch working if i rewrite my package.json like this :

{
"watch": {
    "build": {
      "patterns": [
        "src"
      ],
      "extensions": "jsx"
    }
  },
  "scripts": {
    "start": "node ./scripts/start-non-split.js",
    "build": "node ./scripts/build-non-split.js",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "watch": "npm-watch"
  },
}
M-Zuber commented 3 years ago

The issue has to do with the extensions that nodemon watches by default. So the solution is to use the extended config option with the extensions option set.

@adamborys This should do what you need:

 "watch": {
    "push": {
        "patterns": "*.{js,html}",
        "extensions": "js, html"
  },