如何部署角2应用程序? [英] How to deploy angular 2 apps?
问题描述
如何一旦达到生产阶段部署的角2的应用程序?
How to deploy angular 2 apps once they reach the production phase?
我到目前为止看到即使在angular.io所有导游是精简版的服务器上进行计算,并提供给browserSync反映更改,但是当你开发完你怎么可以发布应用程序?我导入index.html页面所有已编译的js文件或我使用他们的运行如下一饮而尽?将他们的工作?我在所有的生产版本需要SystemJS?
All the guides I've seen so far even on the angular.io is counting on a lite-server for serving and browserSync to reflect changes but when you finish with development how can you publish the app ? do I import all the compiled js file in the index.html page or do I minify them using gulp ? will they work ? do I need SystemJS at all in the production version ?
很抱歉,如果我的问题似乎很简单,但我有点糊涂了?
Sorry if my question seems very basic but I am a bit confused ?
推荐答案
您实际上是在这里一触及两个问题。第一个是如何托管应用程序。而作为@toskv提到它实在太广泛的问题进行回答取决于很多不同的事情。第二个是更具体的 - 你怎么了prepare的应用程序的部署版本。您有几种选择在这里:
You are actually here touching two questions in one. First one is how to host your application. And as @toskv mentioned its really too broad question to be answered and depends on numerous different things. Second one is more specific - how do you prepare the deployment version of the application. You have several options here:
- 部署,因为它是。只是 - 没有缩小,连接,名称重整等Transpile所有的台山项目,所有的js结果/ CSS / ...来源+依赖性复制到托管服务器和你是好去
- 使用特殊的捆绑工具部署。喜欢的WebPack或systemjs建设者。并配备了缺乏在#1,所有的可能性。你可以收拾你所有的应用程序code逼到夫妇JS / CSS / ...文件,你在你的HTML参考的。 Systemjs Builder也随之诞生甚至可以让你摆脱需要包括systemjs作为部署计划的一部分。
是的,你很可能需要部署systemjs和一堆其他外部库作为你的软件包的一部分。是的,你可以将它们捆绑到只是几个你从你的HTML页面引用js文件。您不必引用从这些网页所有的编译js文件 - systemjs作为一个模块加载程序将采取照顾。
Yes you will most likely need to deploy systemjs and bunch of other external libraries as part of your package. And yes you will be able to bundle them into just couple of js files you reference from your html page. You do not have to reference all your compiled js files from the page though - systemjs as a module loader will take care of that.
我知道这听起来很浑 - 帮助您开始使用#2这里有两个真的很好示例应用程序:
I know it sounds muddy - to help get you started with the #2 here are two really good sample applications:
SystemJS建设者: angular2种子
SystemJS builder: angular2 seed
的WebPack: angular2的WebPack起动
看看他们是怎么做的 - 希望这将帮助你找到你的捆绑您的应用程序的方式。
Look how they do it - and hopefully this will help you to find your way of bundling apps you make.
这篇关于如何部署角2应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!