Set default host and port for ng service in configuration file

I want to know if I can set the host and port in the configuration file, so I do not need to enter

ng serve --host foo.bar --port 80 

instead

 ng serve 
+43
angular angular-cli
Jun 11 '16 at 9:29
source share
4 answers

At least Angular CLI 1.0, now you can install them directly in angular-cli.json under the defaults element:

 { "defaults": { "serve": { "port": 4444, "host": "10.1.2.3" } } } 
+73
Mar 14 '17 at 14:24
source share

As of now, this feature is not supported, however if this is what bothers you, the alternative will be in your package. json ...

 "scripts": { "start": "ng serve --host foo.bar --port 80" } 

That way you can just start npm start

Another option, if you want to do this in multiple projects, is to create an alias that you can call ngserve , which will execute your above command.

+35
Jun 13 '16 at 13:08
source share

You can configure the default HTTP port and the one used by the LiveReload server with two command line options:

ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153

https://github.com/angular/angular-cli

+14
Nov 03 '16 at 7:24
source share

You can save them in a file, but you should put it in .ember-cli (at the moment, at least); see https://github.com/angular/angular-cli/issues/1156#issuecomment-227412924

 { "port": 4201, "liveReload": true, "host": "dev.domain.org", "live-reload-port": 49153 } 

edit: now you can install them in angular-cli.json as from commit https://github.com/angular/angular-cli/commit/da255b0808dcbe2f9da62086baec98dacc4b7ec9 which is in build 1.0 0,0-beta.30

+5
Jan 13 '17 at 15:07
source share



All Articles