So far you have configured Grunt to both compile and watch your LESS files. Now it is time to make it refresh your browser window when the watch
plugin notices a change. To do so, perform the following steps:
Gruntfile
and add the livereload
option to the watch
plugin configuration with the help of the following code:watch: {
styles: {
files: ["less/**/*.less"],
tasks: ["less:app"],
options: {
livereload: true,
spawn: false
}
}
}
watch
plugin to start a live-reload server on the default port (35729).index.html
file and add the following script
tag right before the closing body
tag:<script src="http://localhost:35729/livereload.js"></script>
There are also other options for setting up live reloading, such as using browser extensions and the Connect
plugin. For more information, refer to the Live Reloading section in the Watch plugin documentation at https://github.com/gruntjs/grunt-contrib-watch.
Now restart Grunt, navigate to your project root with your browser, change any of your LESS files, and save it. When you do so, your browser should be automatically refreshed.
3.142.173.238