Firebase deploy on save with Gulp



Had time today to get more into Firebase and I’ve managed to hack together a gulpfile - which was from something I previously hacked together from an example @ bradydowling left on the community - that automates firebase deploy on save and worked like a charm for me in Cloud 9. I’ve only today made progress so it’s not fully tested but worked here. I added some vars at the top I try to explain:

var gulp = require('gulp'),
watch = require('gulp-watch'),

//the public folder of Firebase project. Firebase's default is 'public' but I use 'app'.
dir = '/home/ubuntu/workspace/public',

//**THIS is the part I haven\'t tested yet - but _should_ work in therory**
//version can be omitted by setting below 'useVersion' bool to false if staging/prod, etc. is not being used.
version = 'prod',
useVersion = false;

If you have never used gulp it’s fairly strait forward and millions of places to read about it but some pointers perhaps:

  • in a Terminal you’ll need npm install gulp && npm install gulp-watch at least

  • then you’ll need a gulpfile so in a Terminal >> gulpfile.js for example

  • paste the JS from the link below to the new gulpfile.js and back in a Terminal execute gulp init

That should do it. Any feedback’s cool here. Hope it helps. Happy hacking.



Note: Firebase does save every deploy and does not have a mass deletion yet.

**Updated and cleaned up the fiddle to support Cloud Functions
If you’d prefer, here’s a GitHub Gist the of gullpfile.js

Not sure I can update post itself so pinning with solution…