Serving and testing a bundle after ng build

寵の児 提交于 2020-01-22 13:45:28

问题


After I build a bundle with ng build --prod --aot I would like to quickly serve it locally. Is there a way to quickly serve the /dist directory locally using @angular/cli?

I tried to cd dist && ng serve but the dist disappears when the ng serve command is run.


回答1:


http-server is what I use, and it works well.

Install:

npm install -g http-server

cd into your dist folder, type http-server, then enter. Or, just do http-server .\dist at the command line after your application build is successful.

Open a browser, and go to http://127.0.0.1:8080

More info: https://www.npmjs.com/package/http-server

I use this on all my dev machines for running built ng applications.

Or, was there more than simply seeing if the application runs (smoke test) that you were looking for in this?




回答2:


to test easily built angular app I use this angular-http-server

to install it you can do

npm install -g angular-http-server
cd /path/to/site/dist/site
angular-http-server

if you need more info you can check the package npm page angular-http-server



来源:https://stackoverflow.com/questions/43656895/serving-and-testing-a-bundle-after-ng-build

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!