grunt-express icon indicating copy to clipboard operation
grunt-express copied to clipboard

livereload overrides existing watches

Open amctammany opened this issue 10 years ago • 4 comments

I'm running an Express server through my own yeoman generator using grunt-express. I set a watch for Stylus files as such

    stylus: {
        files: ['<%= yeoman.app %>/styles/src/**/*.styl'],
        tasks: ['stylus']
    },

The stylus task works normally when called.

My issue is when I set livereload to true in my express task, the watch it creates overrides the watch I made for stylus files. In my server logs I can see that the .styl file has been modified, but it just reloads it and never calls the stylus task.

Any help would be appreciated.

amctammany avatar Mar 31 '14 23:03 amctammany

I solved my own problem by removing the livereload option from my grunt-express task and set up my own livereload watch using the livereload option provided by grunt-watch and adding the livereload script to my webpage. I still think this it's an issue that grunt-express takes precedence over all other watch calls, but that's just my $0.02.

amctammany avatar Apr 01 '14 00:04 amctammany

Yes, indeed. grunt-express uses grunt-contrib-watch (by setting up dynamic sub-tasks under watch) to perform both serverreload and livereload. The problem is that grunt-contrib-watch has this logic that would basically executes queued tasks sequentially, and in our case, the serverreload creates a watch task that would never complete (so the server can continue running), which blocks other watch tasks. It may take some enhancement from grunt-contrib-watch side to fix this.

blai avatar Apr 30 '14 07:04 blai

I think it would be good to mention in the readme file that serverreload: true and livereload: true are both incompatible with any existing watch tasks. I struggled with this issue quite a bit until I gave up and used grunt-contrib-connect for live-reloading.

levjj avatar Jul 11 '14 21:07 levjj

@levjj totally agree, this issue still exists!!!

flyingsky avatar Sep 24 '14 22:09 flyingsky