Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't livereload , did I miss something? #44

Closed
atian25 opened this issue Jan 9, 2014 · 10 comments
Closed

can't livereload , did I miss something? #44

atian25 opened this issue Jan 9, 2014 · 10 comments

Comments

@atian25
Copy link

atian25 commented Jan 9, 2014

grunt config:

module.exports = function (grunt) {
  'use strict';
  grunt.loadNpmTasks('grunt-express');
  grunt.initConfig({
    express: {
      options: {
        port: 9000,
        hostname: '*'
      },
      server: {
        livereload: true,
        options: {
          serverreload: true,
          livereload: 35729,
          bases: ['src']
        }
      }
    }
  });
  grunt.registerTask('server', ['express', 'express-keepalive']);
}

browser response:

view-source:http://localhost:9000/

<html>
<head>

</head>
<body>
  test
<!-- livereload script -->
<script type="text/javascript">document.write('<script src="http://'
 + (location.host || 'localhost').split(':')[0]
 + ':35729/livereload.js?snipver=1" type="text/javascript"><\/script>')
</script>
</body>
</html>
@bguiz
Copy link

bguiz commented Feb 17, 2014

Not sure if this is related, but when I add grunt-express, using this diff:
https://gist.github.com/bguiz/9042855

... the watch task/ livereload task doesn't appear to detect that code has changed in the specified folders. As far as I can tell, the watch doesn't get triggered, and thus livereload doesn't get called.

@atian25 Did you have any luck with your problem?

@atian25
Copy link
Author

atian25 commented Feb 17, 2014

@bguiz sad, I can got watch trigger log at console, so it may not be the problem with watch

@bguiz
Copy link

bguiz commented Feb 17, 2014

Hmm, can you show me your grunt file @tz ?
On 17 Feb 2014 19:37, "TZ" notifications@github.com wrote:

@bguiz https://github.com/bguiz sad, I can got watch trigger log at
console, so it may not be the problem with watch

Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-35237407
.

@atian25
Copy link
Author

atian25 commented Feb 17, 2014

just as the upon code

@bguiz
Copy link

bguiz commented Feb 17, 2014

Ok. Could you post a gist with your grunt file and package.json? Perhaps
I've missed something
On 17 Feb 2014 20:05, "TZ" notifications@github.com wrote:

just as the upon code

Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-35239122
.

@atian25
Copy link
Author

atian25 commented Feb 17, 2014

here you are: https://gist.github.com/atian25/9047610
and I'm sorry, it's too long ago and forgot.
now found it is the problem of can't trigger watch

@bguiz
Copy link

bguiz commented Feb 17, 2014

I don't get any cannot trigger watch errors myself. I simply get some
similar console output to yours, and no response (nothing triggered) when
SASS/ JS/ HTML files get changed.

It may be a conflict with different versions of npm modules. Any chance you
could add your package.json to the gist?

On 17 February 2014 20:42, TZ notifications@github.com wrote:

here you are: https://gist.github.com/atian25/9047610
and I'm sorry, it's too long ago and forgot.
now found it is the problem of can't trigger watch

Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-35241572
.

@atian25
Copy link
Author

atian25 commented Feb 17, 2014

yes, I had update it with :

  1. the log of npm list : https://gist.github.com/atian25/9047610#file-npm-list
  2. tree of project directory: https://gist.github.com/atian25/9047610#file-tree
  3. package.json : https://gist.github.com/atian25/9047610#file-package-json

@bguiz
Copy link

bguiz commented Feb 18, 2014

@atian25 Thanks for that - I have had a squiz, the only difference is that you are using Grunt 0.4.2, and I am using 0.4.1. I tried 0.4.2, and it didn't make any difference for my project. When I remove grunt-express and reinstate connect (which is what controlled livereload previously), the watch and livereload grunt tasks get triggered correctly once more.

@blai tl;dr=livereload and/ or watch grunt tasks are failing to trigger when grunt-express is used. Do you think you could look into this or point us in the right direction?

@blai
Copy link
Owner

blai commented Apr 30, 2014

livereload and serverreload may not work in parallel with the latest grunt-contrib-watch, as watch is trying to wait for a task to complete before it goes to next: https://github.com/gruntjs/grunt-contrib-watch/blob/master/tasks/lib/taskrunner.js#L175-L190. To help you understand the problem, gruntjs/grunt-contrib-watch#240 has the same problem. I personally think livereload should be separated from the task queue in watch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants