【问题标题】:Adding root folder outside of public to hosting Firebase将公共之外的根文件夹添加到托管 Firebase
【发布时间】:2020-01-03 21:56:46
【问题描述】:

我使用 Firebase 上的不同网站具有以下结构(用于处理不同的主题)。

/src
/theme-1/index.html
/theme-2/index.html

所有的“果汁”都在src 中,index.html 文件对于theme-1theme-2 都是相同的,除了我引用.css 文件的那一行,我实际使用的地方不同的。

目前,我只配置了一个目标,但我会在firebase.json 中添加更多:

{ “托管”:{

    "target": "theme-1",
    "public": "theme-1",
    "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
    ],
    "rewrites": [
        {"source": "**","destination": "/theme-1/index.html"}
    ],
    "cleanUrls": true,
    "headers": [ {
        "source": "**",
        "headers": [ {
          "key": "Cache-Control",
          "value": "max-age=60"
        } ]
     } ]

}

}

然后我使用 cmd 命令配置我的目标以指向我的 firebase 站点:

firebase target:apply hosting theme-1 theme-1

然后部署网站:

firebase deploy

但是,当我访问该页面时(尽管它在本地工作),它似乎无法找到根文件夹 /src(404 错误)。

我怎样才能在我的部署中包含文件夹 /src 以便它以相同的方式工作?

【问题讨论】:

    标签: firebase firebase-hosting


    【解决方案1】:

    只有public 指定的目录才会部署到 Firebase。这个名字有点误导,因为没有“私人”文件/目录。

    所以你必须做"public": "src"(或者"public": ".",如果你也想部署theme目录),并相应地调整其他属性。

    【讨论】:

      猜你喜欢
      • 2018-08-18
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2014-02-03
      • 2019-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多