首先我们安装 https://github.com/remy/nodemon
Either through cloning with git or by using npm (the recommended way):
1 2 |
npm install -g nodemon |
And nodemon will be installed globally to your system path.
It is also possible to install locally:
1 2 |
npm install --save-dev nodemon |
With a local installation, nodemon will not be available in your system path. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as npm start
) or using npx nodemon
.
安装完成后,打开 package.json, 加入: “watch”: “nodemon –watch src -e html,vue,js,less build/build.js”,
1 2 3 4 5 6 7 8 9 |
"scripts": { "dev": "node build/dev-server.js", "watch": "nodemon --watch src -e html,vue,js,less build/build.js", "start": "node build/dev-server.js", "build": "node build/build.js", "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", "e2e": "node test/e2e/runner.js", "test": "npm run unit && npm run e2e" }, |
然后我们启动: npm run watch
1 2 3 4 5 6 7 8 9 |
λ npm run watch > start@1.0.0 watch C:\www\Aweb\vr29\public_html\start\app > nodemon --watch src -e html,vue,js,less build/build.js [nodemon] 1.12.0 [nodemon] to restart at any time, enter `rs` [nodemon] watching: C:\www\Aweb\vr29\public_html\start\app\src/**/* [nodemon] starting `node build/build.js` |
然后有修改就会自动编译了.