Reputation: 5452
I am trying to get livereload working in one website, triggered by different servers, from different projects. I am using Grunt.js with grunt-contrib-connect and grunt-contrib-watch.
Here is an example:
Now let's say, I run a webpage on localhost:9800 that should benefit from livereloading So, in most cases where only one livereload process is present, one would have something like this in localhost:9800/index.html :
<body>
...
<script type="text/javascript" charset="UTF-8" src="//localhost:35729/livereload.js"></script>
</body>
so, with multiple livereload servers, I thought I'd have to include all livereload scripts:
<body>
...
<script type="text/javascript" charset="UTF-8" src="//localhost:33333/livereload.js"></script>
<script type="text/javascript" charset="UTF-8" src="//localhost:44444/livereload.js"></script>
<script type="text/javascript" charset="UTF-8" src="//localhost:55555/livereload.js"></script>
</body>
which is not working. Only the first script will trigger livereload in the browser. In the docs of grunt-contrib-watch, they have an example about running different servers in different targets of the watch task. How do you actually make this work?
Thank you for any help
Here is my watch task for testing:
watch: {
css: {
files: ['www/**/*.css'],
options: {
livereload: 33333
}
},
html: {
files: ['www/**/*.html'],
options: {
livereload: 44444
}
},
js: {
files: ['www/**/*.js'],
options: {
livereload: 55555
}
},
...
}
Upvotes: 4
Views: 466
Reputation: 31
This configuration could not work.
livereload.js instantiates a global object LiveReload see ( livereload-js/src/startup.coffee ). And there is only one web-socket available per LiveReload object, so you could not have on 3 sockets.
I would like to have the same configuration as you, but today I do not find a work around for it
Upvotes: 3