Skip to content

Instantly share code, notes, and snippets.

@joemcgill
Last active August 29, 2015 13:57
Show Gist options
  • Save joemcgill/9901400 to your computer and use it in GitHub Desktop.
Save joemcgill/9901400 to your computer and use it in GitHub Desktop.
This is an example of setting up a grunt watch task to use grunt-contrib-connect and livereload.
// The rest of the grunt file goes here
watch: {
// The rest of your watch tasks go here
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
// YOUR LIST OF FILES TO WATCH
// 'public/index.html',
// 'public/patterns/*/*.html',
// 'public/css/*.css',
// 'public/js/*.js'
]
}
},
connect: {
options: {
port: 9000,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: [
// 'pathname of your web directory relative to the Gruntfile.js'
]
}
},
},
@joemcgill
Copy link
Author

This setup assumes you're ok with using the connect plugin to serve static files via a local node server (which is what connect does). If you need to use livereload with PHP files you should do the whole setup at the watch task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment