node.js - Opening non-default browser with lite-server in angular2 quick start guide -


having followed typescript version of angular 2 quick start guide, wondering if possible, , if how configure lite-server launch browser other default.

it seems lite-server take command line args, served via yargs.argv. , seems yargs attempt parse command line args based on common standards (i.e. if token begins --, represents argument name, otherwise argument value) obtain argv. lite-server attempt use open property gets argv, launches browser via [one of of node packages launches processes]. node-open? xdg -open? not sure, not important me right long assumption (based on looking @ several of these process launchers) correct, optionally take argument defining process launch. if omitted, default browser used since file type open html, happens.

if correct, or @ least gist of it, seems need specify --open chrome, example (assuming chrome in path - working on win machine btw), @ end of lite command defined in package.json.

so like...

"scripts": {     "tsc": "tsc",     "tsc:w": "tsc -w",     "lite": "lite-server",     "lite:c": "lite-server --open chrome",     "lite:f": "lite-server --open firefox ",     "start": "concurrent \"npm run tsc:w\" \"npm run lite\" " }, 

i apologize if seems inane, won't @ computer can test few days, , need know if have answer , can stop researching :). thanks!

recent changes (@2.1.0) let set configs, including browser(s), via bs-config.json:

{   "browser": "chrome" } 

or

{   "browser": ["chrome","firefox"] } 

if want set separate scripts each broswer can following in package.json:

{   "scripts": {     "lite": "lite-server",     "lite:ff": "lite-server --c bs-firefox.json",     "lite:c": "lite-server --c bs-chrome.json",     "lite:ie": "lite-server --c bs-ie.json",     "lite:all": "lite-server --c bs-all.json"   } } 

while it's not best solution since have copy , maintain config in multiple files, seems intended lite-server maintainer. here's current lite-server.js file reference.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -