Upload single file to firebase hosting via CLI or other without deleting existing ones?
Asked Answered
C

2

23

Question:

How to upload a single file to firebase without deleting existing files?

Details:

  • Intent: upload single file without deleting existing files on server

  • Usage: have separate directories on local machine each uploading to a specific folder on server

  • What I've tried: overriding the public dir with firebase deploy -p file.txt, this results in setting root public dir to use that dir.

Ceilometer answered 5/6, 2015 at 23:41 Comment(0)
P
20

Disclosure: I work at Firebase

Firebase hosting's command line tools currently requires that you have the entire web site locally, even though it will only upload the files that were modified since the last deploy.

So your only workaround for not would be to have a single machine where all those directories exist, e.g. something like a build or staging server.

We are aware that this is limiting the number of cases that it can be used for.

Update (December 2018): Firebase Hosting now has a REST API. While this still doesn't officially allow you to deploy a single file, you can use it creatively to get what you want. See my Gist here: https://gist.github.com/puf/e00c34dd82b35c56e91adbc3a9b1c412

Prejudge answered 5/6, 2015 at 23:57 Comment(9)
Hi Frank, thanks for the quick response. This was the work-around I was using, seems to work, I didn't know if it was best-practice. Wasn't sure if it was uploading all files every firebase deploy call or not. As it's a CDN based service makes sense that it would have this limitation.Ceilometer
Is that still the case today (2018) that firebase can only update the whole project?Cletuscleve
@Frank Van Puffelen... Is it possible to support deploying single files on the platform but just in the future? Or this this something the architecture won't ever support?Eldridge
this question is three years old, any update on this?Katherine
Not yet. But keep watching the Firebase blog and release notes for exciting updates on this front. :-)Prejudge
any news about this issue?Indigestion
The CLI will only upload files that have been changed since the last deploy. But in order for it to determine that, you'll still need to have all file locally. If you only have the files you want to deploy, you can use the script in the gist I linked.Prejudge
With release of firebase-tools v11.1.0 the underlying firebase-tools/lib/api object no longer has the request method - unsure of a current way to upload a single file without having the whole published hosting site locally - see github.com/firebase/firebase-tools/pull/4629Unutterable
Oof... good catch Mike. The Hosting team is aware of this and looking at creating a script that does the same thing differently.Prejudge
J
-1

You can modify the firebase.json file to add objects in the rewrites attribute to upload only the files you want. For example:

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [{
      "source": "index.html",
      "destination": "/index.html"
    },
    {
      "source": "css/style.css",
      "destination": "/css/style.css"
    }]
  }
}
Jawbreaker answered 12/1, 2021 at 23:5 Comment(1)
rewrites are not used for this purpose. rewrites rules are for the hosting rewrites.Horseshit

© 2022 - 2024 — McMap. All rights reserved.