Github: johnpapa/lite-server
NPM package: https://www.npmjs.com/package/lite-server
早期的前端对web服务器的依赖是比较小的,现如今移动互联网的推动,前端技术被大大拓宽了,对web服务器的依赖也大大增强了。在此状况下,lite-server是一个非常不错的选择。
summary from offical
Lightweight development only node server that serves a web app, opens it in the browser, refreshes when html or javascript change, injects CSS changes using sockets, and has a fallback page when a route is not found.
- 轻量级仅适用开发的node服务
- 仅支持 web app
- 它能够为你打开浏览器,当你的html或js文件发送变化时,它能自动识别并自动帮你刷新浏览器。
- 还能使用套接字自动注入变化的CSS,
Installation and Usage
Add lite-server and script entry within your project’s package.json file:
1 | # Inside package.json |
Install and run script
1 | $ npm i |
Global Installation
lite-server can be also installed globally, if preferred:
1 | $ npm install -g lite-server |
Custom Configuration 自定义配置
lite-server 使用BrowserSync, 它是允许你去覆盖默认的配置,这得通过你项目里的文件 bs-config.json 或 bs-config.js 来完成
You can provide custom path to your config file via -c or –config= run time options:
1 | lite-server -c configs/bs-config.js |
1 | # bs-config.js |