将Angular 6 Universal部署到GCP App Engine

时间:2018-07-01 23:55:54

标签: node.js angular google-app-engine angular-universal

我正在寻找一个使用Angular 6 Universal并成功部署到GCP App Engine的示例项目。我已经搜索了GitHub,但找不到示例-Universal Starter不包括部署。另外,我的旧Angular 5 Universal配置不适用于这个新的V6项目。

当前错误来自nginx:“ 502错误网关” 似乎是导致问题的favicon.ico文件-看起来像是Node.js问题。我只是在一个纯Node.js项目(不是Angular)上进行了处理,并且能够解决该问题,但是我在Angular上下文中找不到正确的配置。

server.ts

app.use(favicon('src/favicon.ico'));

angular.json(开始)

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "appname": {
      "root": "",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/browser",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              {
                "glob": "favicon.ico",
                "input": "src",
                "output": "/"
              },
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "/assets"
              }
            ],
            "styles": [
              {
                "input": "node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
              },
              "src/styles.css"
            ], ...

dispatch.yaml(因为我有多个服务使用同一域)

dispatch:
  # Default service serves the typical web resources and all static resources.
  - url: "*/favicon.ico"
    service: default

1 个答案:

答案 0 :(得分:1)

问题没有正确启动package.json中的Node。脚本中的这一行解决了问题...

"scripts": {
    ...
    "start": "node dist/server.js",