Grunt uses Gruntfile.js configuration for watch and livereload
Watch angularJS at home on weekends, use the automatic refresh of grunt's livereload for most of the day, post the configuration now, lest you forget it later, there is no problem as long as you follow the configuration step by step
The initial preparation for the environment installation is:
(1): nodeJS, go to the official website to download (href)
(2): then add nodeJS to the global environment variable (after nodeJS is installed, you can use the command npm), refer to (href)
(3): execute npm install grunt- g and npm install-g grunt-cli, one is to install the server-side gurnt and the other is the client-side grunt (just install them anyway), refer to (href)
Step 1: create a new js file called Gruntfile.js
Run the following code
Module.exports = 'package.json'9000'127.0.0.1', livereload: 35729, "html" 35729' * * / * 'default', ["connect", "watch"' grunt-contrib-watch''grunt-contrib-connect' "
2: create a new package.json file and execute npm install directly under cmd (command line) to download all node_module automatically.
Run the following code
{"name": "nono", "version": "0.0.0", "description": "for watch", "main": "Gruntfile.js", "dependencies": {"grunt": "~ 0.4.5", "express": "~ 3.15.2", "grunt-contrib-connect": "~ 0.6.0" "grunt-contrib-watch": "~ 0.5.3"}, "devDependencies": {}, "scripts": {"test": "echo\" Error: no test specified\ "& & exit 1"}, "repository": {"type": "git", "url": "sqqihao.github.com"}, "keywords": ["nono"], "author": "nono" "license": "_ _ MIT__"}
OK, now execute grunt in the current directory, grunt will automatically monitor the changes of all files, and when your files change, all files in html format that you open through 127.0.0.1 will be automatically refreshed.