在开始上传之前,我能否让“ firebase deploy”首先运行“ yarn build”?

时间:2019-06-12 11:31:23

标签: firebase deployment firebase-hosting firebase-cli

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

2 个答案:

答案 0 :(得分:1)

Rubberduck ^ H ^ H ^ HStak救援的溢流: 有一个有效的“ predeploy”挂钩!

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

但是可能我仍然可以在此配置上进行改进? (顺便说一句,是的,数据库规则也将包含在内)

答案 1 :(得分:1)

在您的package.json中尝试一下:

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

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