0

When using firebase functions, is it possible to access/modify the firebase hosting filesystem?

My use case for this would be to have a cloud function run a build script within the hosting's files.

Specifically, being able to run the build script for a hosted Vue application by calling a cloud function.

user3869231
  • 342
  • 1
  • 4
  • 19

1 Answers1

1

You can use firebase-tools as a module which would allow you to do things like deploy, or you can use the Firebase Hosting REST API directly to deploy, but in both cases you will need to maintain your own filesystem with the canonical source of truth. Firebase Hosting is versioned, and each new version must be created and populated with all of its files (you can't just change a single file, for instance).

With a good amount of work, you could use the REST API to effectively copy all of the files from one version into a new one and populate a few small changes, but this is a rather advanced use case and will likely not be straightforward.

In many cases, it will be simpler to use a Cloud Function to dynamically serve the content through Firebase Hosting instead.

Michael Bleigh
  • 25,334
  • 2
  • 79
  • 85
  • Thank you. That makes sense. Serving dynamic content through functions seems much easier than what I was looking to do. – user3869231 Dec 20 '19 at 00:40
  • 1
    For an example of deploying a single change on top of existing deploys, see my answer here: https://stackoverflow.com/questions/30677351/upload-single-file-to-firebase-hosting-via-cli-or-other-without-deleting-existin – Frank van Puffelen Dec 20 '19 at 03:29