没有Web服务器的Angular 2 [英] Angular 2 without Webserver
问题描述
如何在没有Web服务器而只有文件系统的情况下在生产中使用Angular 2?由于公司政策原因,我无法使用网络服务器(这对Angular来说不是问题,因为我可以使用文件系统).
How can I use Angular 2 in production without webserver and just the filesystem? I can't use a webserver because of the corporate policies (that was not a problem with Angular because I could use the filesystem).
推荐答案
如果您不需要网络,则Angular(版本2和更高版本)的应用程序可以在 file:/
协议上正常工作.但是,您必须在 index.html
中设置正确的基本href路径.如果您使用的是Angular CLI,则可以使用以下命令来构建应用程序:
If you don't need network, Angular (version 2 and higher) applications work with no problems over the file:/
protocol. But you must set a correct base href path in your index.html
. If you are using Angular CLI, you can build the app using the following command:
ng build --base-href=/path/to/your/application/dist/
,然后在浏览器中打开 file:///path/to/your/application/dist/index.html
.
and then opening the file:///path/to/your/application/dist/index.html
in your browser.
这篇关于没有Web服务器的Angular 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!