用于 angular 7 的谷歌云应用程序 yaml

DJ-*_*DJ- 4 google-app-engine google-cloud-platform angular

我的项目目录看起来像

**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/(.*)/(.*)
Run Code Online (Sandbox Code Playgroud)

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

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

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

Thi*_*lvo 11

这里分享一下我使用的方法。

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
Run Code Online (Sandbox Code Playgroud)

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

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

/deploy
  app.yaml
  /app  =>  generated by ng build
    index.html
    ...bundles..js
    /assets
      ...
Run Code Online (Sandbox Code Playgroud)

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

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