generator-angular-fullstack icon indicating copy to clipboard operation
generator-angular-fullstack copied to clipboard

Injected LiveReload snippet

Open dapids opened this issue 12 years ago • 15 comments

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

dapids avatar Jun 01 '14 10:06 dapids

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.

dapids avatar Jun 03 '14 08:06 dapids

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?

JaKXz avatar Jun 03 '14 13:06 JaKXz

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

dapids avatar Jun 03 '14 14:06 dapids

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.

DaftMonk avatar Jul 03 '14 14:07 DaftMonk

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?

dapids avatar Jul 07 '14 10:07 dapids

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. ;)

dapids avatar Jul 07 '14 12:07 dapids

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,

yabasha avatar Jul 10 '14 10:07 yabasha

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 avatar Jul 10 '14 10:07 dapids

@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?

yabasha avatar Jul 10 '14 11:07 yabasha

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
        }
      }
      ...
}

dapids avatar Jul 10 '14 12:07 dapids

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:

yabasha avatar Jul 10 '14 12:07 yabasha

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

dapids avatar Jul 10 '14 12:07 dapids

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?

dapids avatar Jul 29 '14 08:07 dapids

Are the changes the same as earlier version? Please tell me what are the changes you made?

yabasha avatar Jul 29 '14 12:07 yabasha

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}));
    ...
}
...

dapids avatar Jul 29 '14 13:07 dapids