想要在 Nuxt.js + Google App Engine 上显示网站图标

时间:2020-12-21 00:18:27

标签: vue.js google-app-engine google-cloud-platform nuxt.js

前提/我想要达到的目标

我正在 Google App Engine 上以 SSR 模式部署 Nuxt.js 应用。 当时已经不再显示favicon,所以希望能够显示。

yarn build + gcloud app deploy

顺便说一句,用下面的命令显示没有任何问题。

yarn dev

yarn build + yarn start

对应的源代码

export default = {  
  head: {
    link: [
      { rel: 'icon',
      type: 'image/x-icon', href: 'images/favicon.ico' }
    ]
  }
}(nuxt.config.js)
runtime: nodejs12

instance_class: F2

handlers:
  - url: /_nuxt
    static_dir: .nuxt/dist/client
    secure: always

  - url: /(.*\.(gif|png|jpg|ico|txt))$
    static_files: static/\1
    upload: static/.*\.(gif|png|jpg|ico|txt)$
    secure: always

  - url: /sw.js
    static_files: static/sw.js
    upload: static/sw.js

  - url: /.*
    script: auto
    secure: always

  - url: /images/favicon.ico
    static_files: static/images/favicon.ico
    upload: static/images/favicon.ico

  - url: /assets
    static_dir: assets

env_variables:
  HOST: '0.0.0.0'
  PORT: '8080'(app.yaml)

我将 favicon.ico 放在 static/images 目录下。

2 个答案:

答案 0 :(得分:0)

从您运行的命令来看,您在部署应用程序时似乎没有声明 app.yaml 文件。

yarn build + gcloud app deploy

试试:

gcloud app deploy app.yaml --project [project-id]

答案 1 :(得分:0)

请看看进App Engine Official Documentation关于如何设置的favicon.ico

在Vuejs应用被管理为静态网站由应用程序引擎作为前端的Vue运行。

因此,你需要配置为使用静态文件的app.yaml。

<强>的app.yaml

var obj = {};
const name = ""; 
const value = cumulator;
obj[name] = value;
dataSourceArray.push(obj);

请看看成以下App Engine documentation在应用程序引擎静态文件。

相关问题