angularangular-clibrowser-syncsockjs

angular-cli: how to tell browsersync (sockjs-node) which port to use


I'm using angular-cli in combination with ASP.NET. Therefor, I create and angular application, which I'm bnuilding with ng serve, which makes the pageages avalible under

<script type="text/javascript" src="http://localhost:4200/i.... (4x)

this scripts are embedded in my ASP.NET page which is avalible under http://localhost:50744/XXXX/XXX and the application is displayed.

However, the live reload doesn't work because it tries to connect to http://localhost:50744/sockjs-node/info?t=1528445601999, so it uses the port of the ASP.NET Site and not the port of 'ng serve'.

How can I tell sockjs-node to use the 4200 port instead of the 50744?

What I tried: I looked at the browser sync doku (https://browsersync.io/docs/options/ ) I couldn't figure out how to set this with angular-cli.

I'm using @angular/cli": "~1.7.4", "@angular/core": "^5.2.0",...


Solution

  • I ended up using

    ng build --watch
    

    and ran my own watcher (browser-sync start --proxy "localhost:XXXX" --files "...")