【发布时间】:2018-03-20 21:34:48
【问题描述】:
我正在使用npm-watch 来监视我的文件是否有更改,但是它只在我的 src 文件夹中立即处理 js 文件,而不是在任何子文件夹中。
我的 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"
}
}
文档没有详细说明如何执行此操作。从它指出的文档中:
This module does very little but run nodemon for you, all credit for the reliable file watching and process restarting should go to there.
所以也许我可以用 nodemon 来完成这个。有什么想法吗?谢谢。
【问题讨论】: