使用Angular CLI 1.6.0时,ng服务使用什么服务器? [英] What server does ng serve use when using Angular CLI 1.6.0?

查看:128
本文介绍了使用Angular CLI 1.6.0时,ng服务使用什么服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Angular CLI 1.6.0时,此Angular CLI命令使用什么服务器?

What server does this Angular CLI command use, when using Angular CLI 1.6.0?

ng serve

由于Angular CLI现在正在使用webpack进行网站捆绑,这是否意味着ng-serve正在使用webpack-dev-server(这是一个Node.js Express服务器)?在以下问题中,有一些迹象表明ng服务可能用于搭载Ember使用的服务器:

Since webpack is now being used by the Angular CLI for the website bundling, does that mean ng-serve is using the webpack-dev-server (which is a Node.js Express server)? There is some indication in the following Q/A that ng serve possibly used to piggyback off a server used by Ember:

运行ng服务时会发生什么?

推荐答案

尝试ng eject 此命令将覆盖您的package.json并在根目录中生成一个名为webpack.config.js的文件.

Try ng eject This command will override your package.json and also generates a file called webpack.config.js in your root directory.

这将为您提供项目正在使用的所有当前webpack配置.

That will give you all the current webpack configuration that your project is using.

执行此操作时,将在package.json中找到它:

When you do that, in your package.json, this is what you'll find :

"scripts": {
    "eject": "ddc eject",
    "build": "webpack",
    "start": "webpack-dev-server",
    "test": "karma start ./karma.conf.js",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "e2e": "protractor ./protractor.conf.js"
  },

如您所见,npm start使用的是webpack-dev-server.

As you can see, npm start is using webpack-dev-server.

注意:要撤消更改,请使用git,否则AngularCli无法提供撤消方法

NOTE: To undo your changes, use git, otherwise AngularCli doesn't provide a way of undoing

这篇关于使用Angular CLI 1.6.0时,ng服务使用什么服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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