首页 > 解决方案 > 用于 Angular 7 的谷歌云应用程序 yaml

问题描述

我的项目目录看起来像

**demo**
 -->
   **ui**-->
     **dist**-->
       **ui**-->
         *.html
         *.js files


In my app.yaml    

runtime: python27
api_version: 1
threadsafe: true`enter code here`
handlers:
- url: /
  static_files: dist/\1/index.html
  upload: dist/(.*)/(.*)

每当我部署我的应用程序并点击 URL 时,我都会看到 404 无法加载资源:服务器以 404 () 的状态响应除 index.html 之外的所有文件。

任何帮助如何进一步进行将不胜感激。

阅读堆栈溢出相关问题但没有运气

标签: angulargoogle-app-enginegoogle-cloud-platform

解决方案


在这里我分享我使用的方法。

app.yaml应该看起来像:

runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /(.+\.js)
  static_files: app/\1
  upload: app/(.+\.js)

- url: /(.+\.css)
  static_files: app/\1
  upload: app/(.+\.css)

- url: /(.+\.png)
  static_files: app/\1
  upload: app/(.+\.png)

- url: /(.+\.jpg)
  static_files: app/\1
  upload: app/(.+\.jpg)

- url: /(.+\.svg)
  static_files: app/\1
  upload: app/(.+\.svg)

- url: /favicon.ico
  static_files: app/favicon.ico
  upload: app/favicon.ico

- url: /(.+\.json)
  static_files: app/\1
  upload: app/(.+\.json)

- url: /(.+)
  static_files: app/index.html
  upload: app/index.html

- url: /
  static_files: app/index.html
  upload: app/index.html

这些处理程序规则可以优化。在这里,我将它们以每种文件类型的详细形式保存。

文件夹的目录结构deploy应如下所示:

/deploy
  app.yaml
  /app  =>  generated by ng build
    index.html
    ...bundles..js
    /assets
      ...

此默认服务将https://YOUR_PROJECT_ID.appspot.com照常提供。

也许这些链接可以帮助您:


推荐阅读