Our angular app will be embedded in an iframe when in production. In development, we have a file, host.html, which has an iframe whose src is the angular app's index page. We can 'ng serve' and then manually bring up host.html and it works fine.
But, 'ng serve -o' wants to open up the app index file; how do I make it open host.html instead?
So I don't think angular cli supports opening an arbitrary page with the -o
option, but you could make your own npm
script that does what you want.
Try opening package.json
and editing the scripts
section to update the start
script like so (mac version):
"scripts": {
"ng": "ng",
// where localhost:4200 is your dev host and port, respectively
"start": "ng serve && open http://localhost:4200/host.html",
"build": "ng build",
...
},
Depending on what platform you're using, the script would need to be written differently:
// Windows
"start":"ng serve & start http://localhost:4200/host.html"
// Mac
"start":"ng serve && open http://localhost:4200/host.html"
// Linux
"start":"ng serve && xdg-open http://localhost:4200/host.html"
Then, instead of using ng serve
to start your app, use npm start
.
Reference: used this SO answer for the platform specific open
commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With