angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Launch site after ng serve?

Open rburnham52 opened this issue 10 years ago • 8 comments

Is it possible to have ng serve launch your site after it starts up? I find this easier than having to copy the localhost with port address from the terminal and paste it into a new browser tab

rburnham52 avatar Jun 29 '16 11:06 rburnham52

This could be pretty easy to implement. I've done this before with the OPN package https://www.npmjs.com/package/opn.

There could be an additional flag on the serve command similar to the ones below:

  • ng serve --browser to open the default browser
  • ng serve --browser=firefox to open a specific browser

If anyone else thinks this is a good idea I may try a pull-request at this one.

austingreendev avatar Jun 29 '16 21:06 austingreendev

Being able to select a browser like you suggested would be a nice touch as well.

rburnham52 avatar Jul 01 '16 02:07 rburnham52

Dupe of https://github.com/angular/angular-cli/issues/1081

filipesilva avatar Jul 04 '16 00:07 filipesilva

Please feel free to continue the discussion and proposals in the other issue though!

filipesilva avatar Jul 04 '16 00:07 filipesilva

@austin94 do you mind show how you implement OPN?

keepscoding avatar Jul 25 '16 01:07 keepscoding

@keepscoding This conversation should probably be moved to the duplicate issue if that's still active, but from opn README https://www.npmjs.com/package/opn (or you can use the opn-cli package) we could just grab the port that it was started on and add the app name based off of a argument passed in.

// specify the app to open in 
opn('http://localhost:3000', {app: 'firefox'});
opn('http://localhost:3000', {app: 'google chrome'});

// for default browser
opn('http://localhost:3000');

austingreendev avatar Jul 25 '16 02:07 austingreendev

@austin94 where to add these code e.g. open default browser?

keepscoding avatar Jul 25 '16 03:07 keepscoding

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.