gruntjs / grunt-contrib-watch

Run tasks whenever watched files change.
http://gruntjs.com/
MIT License
1.98k stars 356 forks source link

If you edit files directly on your remote development server #203

Open itaine opened 11 years ago

itaine commented 11 years ago

I do all my development in a remote linux env. Is it possible to do the same thing with contrib-watch that can be done with guard and guard-livereload (port forwarding and so forth) as stated in this livereload doc?

shama commented 11 years ago

I'm not familiar enough with how guard works to compare the two.

I don't think you need to forward the local port though. If you have grunt running on your remote dev server then just setup livereload as normal instructed by the docs here: https://github.com/gruntjs/grunt-contrib-watch#optionslivereload

I use the chrome live reload extension with a remote dev server and it works without any additional steps (besides making sure the live reload port is open in iptables). Manually inserting the script tag or using the livereload option in grunt-contrib-connect inject the script tag for you works too.

itaine commented 11 years ago

Ok I open the port with: sudo iptables -A INPUT -p tcp -m tcp --dport 35729 -j ACCEPT sudo iptables-save

and Joy! The livereload chrome plugin connects with the server. I get the following in the console: http://127.0.0.1:35729/livereload.js?ext=Chrome&extver=2.0.9

However, the window doesn't refresh on file change. So now i'm thinking it must be the gruntfile. Am I doing it wrong?

· · watch: {
· · · options: {
· · · · livereload: true
· · · },
· · · css: {
· · · · files: ['source/sass/{,**/}*.{scss,sass}'],
· · · · tasks: ['compass:dev']
· · · },
· · · // js: {
· · · // ·files: '<%= jshint.all %>',
· · · // ·tasks: ['jshint', 'uglify:dev']
· · · // },
· · · livereload: {
· · · · files: [
· · · · · 'public/css/{,**/}*.css',
· · · · · 'public/js/{,**/}*.js',
· · · · · 'img/{,**/}*.{png,jpg,jpeg,gif,webp,svg}'
· · · · ]
· · · }
· · },
· //}}}
· // CONCURRENT {{{
· · concurrent: {
· · · dev: {
· · · · options: {logConcurrentOutput: true},
· · · · tasks: [
· · · · · 'nodemon:dev',
· · · · · 'watch'
· · · · ]
· · · }
· · }
· //}}}

· });
//}}}
// LOAD PLUGINS  ----------------------------------------------------- 2 lines-|
// REGISTER TASKS {{{
· grunt.registerTask('dev', [
· · 'jshint:dev',
· · 'compass:dev',
· · 'concurrent:dev'
· ]);
//}}}
// http://serverfault.com/questions/182070/ubuntu-iptables-open-port
};