Skip to content

Running Locally

Filip Lauc edited this page Jul 1, 2021 · 6 revisions

Requirements

Scripts

  • start:emulator - Starts all required firebase emulators. This includes firestore, storage, auth and hosting, if you end up adding anything else you'll need to include it in the emulators as well by adding it to firestore.json. By default data is persisted between runs, but you can prevent it by removing --export-on-exit=.emulator-export --import=.emulator-export from the script.
  • start:cms - Runs the client app in watch mode. Alternatively start:cms:live targets the live project rather then the emulator.
  • start:functions:watch - Runs the functions in watch mode.
  • start:setup - seeds the data with collections defined in setup/collections.

You can run everything at once with npm run dev this will run: functions in watch mode, emulator suite and the client app. However, this is a very resource intensive script and you don't typically need everything running at the same time so we find our self's running npm run start:cms and npm run start:emulator more often.

Initial Setup

In order to open the cms you'll need to have a user with a role of either "admin" or "user" (or something else if you changed the default). You can run start:setup to populate the initial user-invites and then head to the authentication page in your emulator UI and create a user with that email, or alternatively go straight to the authentication page and create a user with custom claims {"role": "admin"}.

Frequent Issues

Data not persisting between emulator sessions.

TODO: Answer

A port is already occupied and the emulator can't start.

You can change any of the default ports in firebase.json but in case of firstore you'll also need to adjust the port in setup/package.json and client/integrations/firebase/fb.module.ts.