Injected LiveReload snippet
Hi guys,
Do you know how I could change the default port in the injected livereload snippet?
I've edited the connect-livereload plugin, but the injected snippet keeps being using the default port (35729). At this stage I'm not even sure that angular-fullstack uses connect-livereload to inject the livereload snippet in the html code.
Thanks in advance for your help.
Wish you all a wonderful Sunday, David
Well, maybe I am wrong, but this looks to me more like a bug than a question.
In generator-angular, when I change the livereload port in Gruntfile.js, the injected snippet looks for a connection on that port.
In generator-angular-fullstack, instead, the injected snippet still keeps looking for the default port.
Interesting. I marked it as a question because I don't know what functionality it's blocking. What are you trying to accomplish by doing this?
What I am trying to accomplish is to use a different port for livereload.
Now, with generator-angular this works just fine: it is enough to change the livereload option in the Gruntfile and:
- the server starts on the new port;
- the injected snippet establishes a connection to that port.
If I try to do the same in generator-angular-fullstack:
- the server starts on the new port (I think);
- the injected snippet tries to establish a connection to the DEFAULT port, by causing of course the following error:
GET http://eelbob-leaper.codio.io:35729/livereload.js?snipver=1 net::ERR_CONNECTION_TIMED_OUT
There are two factors required for changing the livereload port. Theres the livereload server, which is created by the grunt-watch task, and the connect-livereload middleware which is used by the express server to inject the connect livereload snippet into served pages. Make sure you change the port in both places.
Hi @DaftMonk and thanks for your reply.
Yes, I am changing the port in both places and I still get the same error.
The problem is surely related to the connect-livereload middleware, since the injected snippet's port keeps being always the same (35729), even if I specify a different one with:
app.use(require('connect-livereload')({port: 30000}));
Any thoughts? Am I missing something?
Ok, I am sorry for the false alarm. I don't know how, but now everything is working. Setting up a different port for the connect-livereload middleware produces the expected result. I still don't know what caused the issue, for it started working properly without any change in the code. If I find out, I'll write it here.
A wonderful day to you all. ;)
Hi @dapids please what changes you did?, cause I did the following changes but didn't work:
app.use(require('connect-livereload')({port: 4000}));//in express.js
//under livereload watch task options: { livereload: 4000 }
Thanx for your help,
Hi @yabasha,
The change you made in /lib/config/express.js looks correct to me.
Regarding /Gruntfile.js, I needed to change the livereload port in 3 different parts of the document:
- watch > js;
- watch > livereload;
- watch >express.
Have you done the same?
@dapids I did the changes inside the watch task as following:
watch: {
.
.
livereload: {
.
options: { livereload: 4000 }
},
express: {
.
options: {
livereload: 4000,
nospawn: true //Without this option specified express won't be reloaded
}
.
Where should I change more?
Here is what I've changed:
watch: {
js: {
...
options: {
livereload: 30000
}
},
...
livereload: {
...
options: {
livereload: 30000
}
},
...
express: {
...
options: {
livereload: 30000,
nospawn: true //Without this option specified express won't be reloaded
}
}
...
}
I'm using the latest version of the generator (2.0.4), and I don't have js: sub task for watch:
There is a sub task jsTest:
Uhm, I understand.
I'm using the version 1.3.2 instead.
As soon as I have some free time I'll make a test with your same version.
Cheers, David
Hello @yabasha,
Sorry for the tremendous delay I'm answering you with.
However I made some tests and everything looks just fine.
Version used: 2.0.7
Are you still experiencing troubles?
Are the changes the same as earlier version? Please tell me what are the changes you made?
Gruntfile.js:
watch: {
...
livereload: {
...
options: {
livereload: 30000
}
},
...
express: {
...
options: {
livereload: 30000,
nospawn: true //Without this option specified express won't be reloaded
}
}
...
}
server/config/express.js:
...
if ('development' === env || 'test' === env) {
app.use(require('connect-livereload')({port: 30000}));
...
}
...