热门搜索 :
考研考公
您的当前位置:首页正文

angular 在磁盘上运行服务

来源:东饰资讯网

Serve from Disk

在磁盘上运行服务

If you wish to get a similar experience with the application output to disk please use the steps below. This practice will allow you to ensure that serving the contents of your dist dir will be closer to how your application will behave when it is deployed.
如果您希望获得与应用程序输出到磁盘相似的体验,请使用以下步骤。这种做法将允许您确保提供远程目录的内容将更接近您的应用程序在部署时的行为方式。

Environment Setup

环境设置

Install a web server

安装一个web服务器

Usage

使用

You will need two terminals to get the live-reload experience. The first will run the build in a watch mode to compile the application to the dist folder. The second will run the web server against the dist folder. The combination of these two processes will mimic the same behavior of ng serve.
您将需要两个终端才能获得实时加载体验。第一个将以监视模式运行构建以将应用程序编译到 dist 文件夹。第二个将针对 dist 文件夹运行Web服务器。这两个过程的结合将模拟ng服务的相同行为。

1st terminal - Start the build

第一个终端,开始构建

ng build --watch

2nd terminal - Start the web server

第二个终端。开始web服务器

lite-server --baseDir="dist"

When using lite-server the default browser will open to the appropriate URL.
使用 lite-server 时,默认浏览器将打开相应的URL。

Top