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

前端 未结 7 1303
庸人自扰
庸人自扰 2021-02-05 08:14

Having followed the TypeScript version of the Angular 2 Quick Start guide, I was wondering if it is possible, and if so how to configure the lite-server to launch a browser othe

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 08:49

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

    {
      "browser": "chrome"
    }
    

    or

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

    If you want to set up separate scripts for each broswer you can do the following in your 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 the best solution since you have to copy and maintain your config in multiple files, it seems to be what is intended by the lite-server maintainer. Here's the current lite-server.js file for reference.

提交回复
热议问题