【问题标题】:Production of Angular2 projectAngular2项目的制作
【发布时间】:2017-01-07 20:56:42
【问题描述】:

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

一次性设置

npm install -g angular-cli

ng init 来自 projectFolder,如果它是现有应用程序 ng new projectFolder 如果它是一个新应用程序。

捆绑步骤

ng build --prod --aot(目录为projectFolder时在命令行中运行) 标记 prod bundle for production 和标记 aot 启用提前编译,也称为离线编译。

bundle 默认生成到 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 时,我只收到加载...而没有其他内容。 我如何才能收到正式版?

【问题讨论】:

  • 你是双击index.html打开项目吗? :O
  • 如果我看到加载...,似乎我双击了
  • chrome 控制台有什么错误吗?
  • 双击??... :-(
  • 我在 node.js 命令提示符中做,没有错误信息

标签: angular


【解决方案1】:

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

官方文档是here

【讨论】:

  • 我想在本地加载项目,就像您发送的文档一样,但是当我加载 localhost:4200 时,我只看到标题“应用程序有效!”
  • @Alice 你在关注哪些文档?我已经链接了 2。您希望看到什么?
  • ))) 我希望看到我在执行 npm start 时看到的结果。我正在关注第一个(Angular 2 入门)
  • @Alice 这就是你应该看到的,因为它只是一个教程。它只创建一个带有title = 'app works!'; 的组件。这是github链接:github.com/angular/…
猜你喜欢
  • 1970-01-01
  • 2017-04-04
  • 1970-01-01
  • 1970-01-01
  • 2017-06-11
  • 1970-01-01
  • 2017-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多