使用 Angular CLI 1.6.0 时,ng serve 使用什么服务器?
当使用 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 服务器)?以下 Q/A 中有一些迹象表明 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:
Try 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