How can you specify UI port for lite-server?

旧时模样 提交于 2019-11-27 07:43:28

问题


When you start up lite-server, you can specify port for example

lite-server -- port 8000

Which gives you the following result:

[BS] Access URLs:
 ------------------------------------
       Local: http://localhost:8000
    External: http://192.168.0.5:8000
 ------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.0.5:3001

How can I change the port for UI which is 3001 by default (either command line and/or in bs-config.json file), to like 8001?


回答1:


Since lite-server uses browsersync, it can be changed via BrowserSync options

Not sure about command line parameter, but bs-config.json works like this:

{
  "port": 8000,
  "files": ["./dist/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./" },
  "ui": {
    "port": 8001
  }
}

BrowserSync command line options (that also work with lite-server)




回答2:


just too add, for slow thinkers like me, to run lite-server on different port, create file bs-config.json in root of your project (or whereever you are running lite-server from) and add this into your bs-config.json

{
    "port": 8080
}

this will run lite server on port 8080

alternativelly you can just pass path of the bs-config.json on running lite-server

lite-server -c configs/my-bs-config.json

source: https://github.com/johnpapa/lite-server#custom-configuration



来源:https://stackoverflow.com/questions/35516783/how-can-you-specify-ui-port-for-lite-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!