ng构建后提供服务并测试软件包 [英] Serving and testing a bundle after ng build

查看:68
本文介绍了ng构建后提供服务并测试软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ng build --prod --aot构建捆绑包后,我想在本地快速投放该捆绑包.有没有一种方法可以使用@ angular/cli在本地快速提供/dist目录?

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?

我尝试执行cd dist && ng serve,但是当ng serve命令运行时,dist消失了.

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

推荐答案

http-server是我使用的,并且效果很好.

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

安装:

npm install -g http-server

cd进入dist文件夹,键入http-server,然后输入.或者,只需在应用程序构建成功后在命令行中执行http-server .\dist.

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.

打开浏览器,然后转到http://127.0.0.1:8080

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

更多信息: https://www.npmjs.com/package/http-server

我在所有开发机上都使用它来运行内置的ng应用程序.

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?

这篇关于ng构建后提供服务并测试软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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