lite-server
轻量级的仅适用于开发 的 node 服务器, 它仅支持 web app, 它能够为你打开浏览器, 当你的html或是JavaScript文件变化时,它会识别到并自动帮你刷新浏览器, 还能使用套接字自动注入变化的CSS, 当路由没有被找到时,它将自动后退页面。
Why
在一个轻量级的开发服务器中,浏览器同步能够支持我们的大多数需求. 它提供静态的内容, 监测文本变化, 刷新浏览器, 并且提供更多自定义功能.
When creating a SPA there are routes that are only known to the browser. For example, /customer/21 may be a client side route for an Angular
app. If this route is entered manually or linked to directly as the entry point of the Angular app (aka a deep link) the static server will receive the request, because Angular is not loaded yet. The server will not find a match for the route and thus return
a 404. The desired behavior in this case is to return the index.html (or whatever starting page of the app we have defined). BrowserSync does
not automatically allow for a fallback page. But it does allow for custom middleware. This is where lite-server steps in.
lite-server is a simple customized wrapper around BrowserSync to make it easy to serve SPAs.
安装与使用
以下是被推荐的安装lite-server的方式:
$ npm install lite-server --save-dev
在你的项目中的 package.json 文件中添加一个
“script” 入口:
lite-server是一款轻量级Node.js服务器,专为开发环境设计。它支持自动打开浏览器,并能在HTML或JavaScript文件发生变化时自动刷新页面。此外,lite-server还支持CSS自动注入更新及未找到路由时的自动回退功能,特别适合单页应用(SPA)的开发。
750

被折叠的 条评论
为什么被折叠?



