【问题标题】:Is this the correct way to deploy an Angular Universal project when using the Universal-CLI?这是在使用 Universal-CLI 时部署 Angular Universal 项目的正确方法吗?
【发布时间】:2017-03-21 08:10:34
【问题描述】:

对于过去的 Angular 2 项目,我会将静态 dist 文件夹从 Angular CLI 构建上传到 Google Cloud Platform。我会在这个 app.yaml 文件中使用带有命令 gcloud app deploy app.yaml 的 SDK:

application: 
version: 
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /(.*\.(gif|png|jpeg|jpg|css|js)(|\.map))$
  static_files: dist/\1
  upload: dist/(.*)(|\.map)

- url: /(.*)
  static_files: dist/index.html
  upload: dist/index.html

我已经开始使用Universal-CLI。它也使用ung build 命令生成一个 dist 文件夹。

documentation 概述了服务器渲染的两种方法。这个 dist 文件夹是第一种方法的意思吗:

第一个选项是预渲染您的应用程序,这意味着您将使用通用构建工具之一(即 gulp、grunt、broccoli、webpack 等)在构建时为您的所有路由生成静态 HTML。然后您可以将该静态 HTML 部署到 CDN。

如果我部署 dist 文件夹的方式与上面概述的过去 Angular 2 项目相同,Angular Universal 是否按预期工作?

如果不是,应该如何部署 Angular Universal 项目?

【问题讨论】:

    标签: angular google-app-engine google-cloud-platform angular-universal


    【解决方案1】:

    这里有点晚了。无论哪种方式,以防有人仍在寻找这个。

    这就是我最终要做的。 我将我的代码仓库 (包含整个应用程序的文件夹减去 node_modules 等) 转移到域文件夹中。 (public_html 或任何你使用的)

    在这之后,我运行了这两个命令。

    npm install
    npm start
    

    基本上,在您的服务器中安装所有必需的依赖项并启动您的服务器。

    第二个命令 npm start 直接适用于如果您从 here 为 Angular CLI 和 Universal 构建的出色入门应用程序构建了您的项目。如果没有,请使用您在开发中启动应用程序时使用的任何命令。

    【讨论】:

      猜你喜欢
      • 2019-10-02
      • 1970-01-01
      • 2020-02-20
      • 2018-08-08
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 2020-08-14
      • 1970-01-01
      相关资源
      最近更新 更多