16

I have a small front-end project with javascript running on firebase hosting and I have to call the build script manually before every time I run firebase deploy. So I was looking for a way to put it in a pre-deploy script but there's no such thing in firebase CLI documentation. So anyone has any idea how to make it done?

2 Answers 2

27

Predeploy supports in latest Firebase CLI, please update your CLI and create predeploy in firebase.json file.

"hosting": {
  "predeploy": "npm run build",
  "public": "build",
2
  • 1
    That's really amazing! Thanks! Jul 16, 2020 at 17:13
  • 1
    Interesting... I am trying to use this to build a different flavour of the app (to deploy it to different environments)... it runs my custom pre-deploy build command... but then it ALSO runs the standard one which overrides the former... not sure how to fix this. May 3 at 11:45
10

There is documentation for predeploy hooks with the Firebase CLI.

For any of the assets you can deploy—hosting, functions, database, storage, and firestore— you can add predeploy and postdeploy hooks in firebase.json, and your scripts will run with the corresponding deployment command. Both predeploy and postdeploy hooks print the standard output and error streams of the scripts to the terminal.

For example:

 {
   "hosting":{
     "postdeploy":"./messageSlack.sh 'Just deployed to Firebase Hosting'",
     "public":"public"
   }
 }
1
  • oh there it is, don't know why it does not appear in the search result. thank you very much
    – Hank Phung
    Feb 27, 2018 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.