【问题标题】:Can I get `firebase deploy` to first run `yarn build` before starting the upload?我可以让`firebase deploy`在开始上传之前先运行`yarn build`吗?
【发布时间】:2019-06-12 11:31:23
【问题描述】:

作为开发人员, 正确部署我的 React 项目, 我希望firebase deploy --only hosting 在开始上传之前自动运行yarn build

【问题讨论】:

    标签: firebase deployment firebase-hosting firebase-cli


    【解决方案1】:

    我发现有一个“预部署”挂钩有效!

    {
      "functions": {
        "predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint"]
      },
      "hosting": {
        "predeploy": [
          "cd client && yarn run build"
        ],
        "public": "client/build",
        "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
      }
    }
    
    

    【讨论】:

      【解决方案2】:

      在您的 package.json 中试试这个:

      {
        "scripts": {
          "deploy": "yarn build && firebase deploy --only hosting"
        },
      }
      

      然后你可以从命令行运行npm run deploy

      【讨论】:

      • 如果您在本地部署密钥,则可以使用。在我的情况下,必须在云中保护部署密钥。此外,Firebase 错误意味着我们必须使用自定义的 firebase-action Docker 映像,其中包含有效版本的 firebase 命令。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-25
      • 2020-01-27
      • 1970-01-01
      • 2014-06-18
      • 2020-10-01
      • 1970-01-01
      相关资源
      最近更新 更多