运行 ng serve 时会发生什么? [英] What happens when you run ng serve?

查看:87
本文介绍了运行 ng serve 时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近一段时间我一直在使用 Angular-CLI.它带有许多命令,包括 ng serve,它在 localhost:4200 处启动服务器.

I've been using Angular-CLI for the last little while. It comes with a number of commands including ng serve which spins up a server at localhost:4200.

我习惯使用 Grunt 和 Gulp,它们可以根据我的需要进行配置.我想配置 Angular-CLI 的服务器,但后来我意识到我不知道它是什么或如何配置它.为 serve 搜索项目并没有发现任何有用的东西.

I'm used to using Grunt and Gulp which can be configured to suit my needs. I wanted to configure Angular-CLI's server but then I realized I didn't know what it was or how to configure it. Grepping the project for serve hasn't unearthed anything that seems useful.

那么,ng serve 到底做了什么?

So, what exactly does ng serve do?

推荐答案

现在,它使用 webpack-dev-server 来启动本地网络服务器.请参阅这个问题.

Nowadays, it uses webpack-dev-server to start a local webserver. See this question.

来自文档:

CLI 支持通过运行 ng serve 为用户运行实时浏览器重新加载体验.这将在文件保存时编译应用程序,并使用新编译的应用程序重新加载浏览器.这是通过将应用程序托管在内存中并通过 webpack-dev-server 提供服务来完成的.

The CLI supports running a live browser reload experience to users by running ng serve. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via webpack-dev-server.

<小时>

原答案:

经过一番研究,我收集到了这些.

After some research here's what I've gathered.

Angular-CLI 搭载了 Ember CLI 的某些东西.看起来 ng serve 就是其中之一.Ember 有一个 ember server 命令,它定义在 这个文件 并且似乎与 ng serve 的行为相匹配.

Angular-CLI piggybacks certain things off of Ember CLI. It would appear that ng serve is one of those things. Ember has an ember server command which is defined in this file and seems to match the behavior of ng serve.

这篇关于运行 ng serve 时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆