- Clone the repo
- Install dependencies(npm recommended)
- Download runtime config via
npm run appconfig
- Use one of the scripts from the list below
Topic | Script |
---|---|
General development | serve |
Development SSR build | build:all:dev |
Production SSR build | build:all |
Interact with SSR | firebase serve |
Download runtime config | appconfig |
- The SSR part was initially generated using Angular CLI as described in official docs
- Since the project heavily depends on Firebase services(using AngularFire wrapper) we need to some fixes in regards building/packaging firebase sources:
- [
webpack.server.config.js
] Point out modules resolution order inresolve.mainFields
- [
webpack.server.config.js
] Modifyexternals
- add/^firebase/
entry since Firebase has some troubles being bundled when in the Node environment - [
webpack.server.config.js
] Provideoutput.libraryTarget
&output.library
data because we want to run out SSR server in the Firebase function calledssr
- Move firebase web config into functions remote config. You can download remote config using
npm run appconfig
- [
src/app/core/core.module.ts
] Replace genericAngularFireModule.initializeApp({ })
with manual initialization ofFirebaseOptionsToken
with value fromenvironment
- [
server.ts
file generated by Angular CLI was enhanced with logging and some fixes:- Add important pollyfils for firebase running in node
- Rewrite
Express.Request.originalUrl
from to absolute to relative path. Original url initially comes ashttps://{firebase-project-id}/{page-route}
. We need to get rid of the first part for Angular Router to correctly resolve path within the frontend app navigation - Instead of listening the SSR server it needs to be exported for cloud function to actually run it
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.