生产Angular2项目

时间:2017-01-07 20:56:43

标签: angular

这是我的第一个angular2项目制作。 我在这个网站上使用了这个答案。 使用Angular CLI 1.0.0-beta.24的2.4.x FINAL(TypeScript)

OneTime设置

npm install -g angular-cli
如果是现有应用程序,则从projectFolder

ng init 如果它是一个新的应用程序,则为new projectFolder。

捆绑步骤

ng build --prod --aot(当目录为projectFolder时在命令行中运行) 用于生产的flag prod bundle和flag aot启用提前编译,也称为脱机编译。

默认情况下,

捆绑包会生成到projectFolder / dist /

输出

dist/main.[hash].bundle.js Your application bundled [ size: 13 KB for new Angular CLI application empty, ~3 KB compressed].
dist/vendor.[hash].bundle.js Your dependencies (@angular, RxJS...) bundled [ size: 437 KB for new Angular CLI application empty, 98 KB compressed].
dist/index.html entry point of your application.
dist/inline.js webpack loader
dist/style.[hash].bundle.css the style definitions
dist/assetsresources copied from projectFolder/src/assets
dist/*.[hash].bundle.map the SourceMaps corresponding to the previous files (it is not required for a production deployment)

但是当我点击dist / index.html时,我只收到加载...而没有别的。 我怎样才能收到生产版本?

1 个答案:

答案 0 :(得分:1)

双击index.html,无法打开/引导Angular2项目。您需要一个后端(nodejs,lite-server)或部署服务器(托管主机站点或apache tomcat服务器)。

官方文档为here

相关问题