gpt4 book ai didi

Firebase部署,忽略除公用文件夹外的所有文件

转载 作者:行者123 更新时间:2023-12-04 22:57:18 24 4
gpt4 key购买 nike

我正在尝试清理到Firebase的部署过程,并且在将文件部署到主机时需要忽略除/dist aka公用文件夹之外的所有文件。我相信可以通过ignore中的firebase.json设置来完成,但是除了手动指定所有文件之外,我不确定如何实现它。

示例.json:

{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"ignore": [
// ignore all other files besides dist folder here
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}

最佳答案

使用全局**ignore any file or folder in an arbitrary sub-directory

然后,您可以使用dist取消忽略!dist文件夹

因此,您的firebase.json文件如下所示:

{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"ignore": [
"**",
"!dist/**"
],
"rewrites": [{
"source": "**",
"destination": "/index.html"
}
]
}
}

对于较新版本的Firebase:

似乎新版本的firebase不允许上述方法,因此只需定义应忽略的文件夹即可:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"ignore": [
"**/node_modules/**",
"**/src/**",
"**/public/**"
],
"rewrites": [{
"source": "**",
"destination": "/index.html"
}
]
}
}

您可以使用Firebase控制台检查已部署了多少文件:
  • 打开Firebase项目的“托管”页面,并记下文件数。 Firebase Hosting dashboard
  • 运行命令$ tree dist/(因为在这种情况下dist/是我们在Firebase托管上提供的文件夹),并记下build文件夹中的文件数。
    tree for build folder

  • 这些文件的数量应大致相同。

    关于Firebase部署,忽略除公用文件夹外的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39936217/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com