I'm using npm-watch to watch my files for changes however it's only working on js files immediately in my src folder and not in any subfolders.
My package.json:
{
"name": "dla",
"version": "1.0.0",
"description": "",
"main": "src\\index.js",
"scripts": {
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "npm-watch"
},
"babel": {
"presets": [
"env"
]
},
"watch": {
"build": "src/*.js" <---HERE
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"css-loader": "^0.28.11",
"jquery": "^3.3.1",
"prop-types": "^15.6.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"style-loader": "^0.20.3"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.3",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"npm-watch": "^0.3.0",
"webpack": "^4.0.1",
"webpack-cli": "^2.0.9"
}
}
The documentation isn't very detailed on how to do this. From the documentation it states:
This module does very little but run nodemon for you, all credit for the reliable file watching and process restarting should go to there.
So perhaps I can accomplish this with nodemon. Any thoughts? Thanks.
Set the glob pattern to use the double glob stars (**
) as follows:
"watch": {
"build": "src/**/*.js"
},
This glob pattern; src/**/*.js
, will find all .js
files in the src/
directory and sub-directories of the src/
directory (many levels deep).