Skip to content

Commit 088320d

Browse files
committed
Merge branch 'fix/2'
2 parents 6977a54 + 2c94210 commit 088320d

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build": {
1212
"builder": "@angular-devkit/build-angular:browser",
1313
"options": {
14-
"outputPath": "dist",
14+
"outputPath": "functions/dist/browser",
1515
"index": "src/index.html",
1616
"main": "src/main.ts",
1717
"tsConfig": "src/tsconfig.app.json",
@@ -94,7 +94,7 @@
9494
"server": {
9595
"builder": "@angular-devkit/build-angular:server",
9696
"options": {
97-
"outputPath": "functions/dist-ssr",
97+
"outputPath": "functions/dist/server",
9898
"main": "src/main-ssr.ts",
9999
"tsConfig": "src/tsconfig.app-ssr.json"
100100
}

firebase.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"**/node_modules/**"
88
],
99
"rewrites": [
10+
{
11+
"source" : "**/*.@(css|js)",
12+
"destination": "/index2.html"
13+
},
1014
{
1115
"source": "**",
1216
"function": "ssr"

functions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { AppServerModuleNgFactory } = require('./dist/server/main');
1111
enableProdMode();
1212

1313
const index = require('fs')
14-
.readFileSync(path.resolve(__dirname, './dist/index.html'), 'utf8')
14+
.readFileSync(path.resolve(__dirname, './dist/browser/index.html'), 'utf8')
1515
.toString();
1616

1717
let app = express();

src/app/app.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!--The content below is only a placeholder and can be replaced.-->
22
<div style="text-align:center">
33
<h1>
4-
Server side rendering with Firebase 🔥
4+
{{renderer}} side rendering with Firebase 🔥
55
</h1>
66
<img width="300" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTg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jUsNTIuMUwxMjUsNTIuMQ0KCQlMMTI1LDUyLjF6IE0xNDIsMTM1LjRIMTA4bDE3LTQwLjlMMTQyLDEzNS40eiIvPg0KPC9nPg0KPC9zdmc+DQo=">
7+
<div [ngStyle]="{ 'padding-top': '32px', 'text-align': 'center' }">
8+
<button (click)="openAlert()">Is browser code loaded?</button>
9+
</div>
710
</div>

src/app/app.component.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
import { Component } from '@angular/core';
1+
declare let window: any;
2+
3+
import { Component, OnInit, Inject, PLATFORM_ID } from '@angular/core';
4+
import { isPlatformBrowser } from '@angular/common';
25

36
@Component({
47
selector: 'app-root',
58
templateUrl: './app.component.html',
69
styleUrls: ['./app.component.css']
710
})
8-
export class AppComponent {
9-
title = 'app';
11+
export class AppComponent implements OnInit {
12+
renderer = '';
13+
14+
constructor(@Inject(PLATFORM_ID) private platformId: string) {}
15+
16+
ngOnInit() {
17+
this.renderer = isPlatformBrowser(this.platformId) ? 'Browser' : 'Server';
18+
}
19+
20+
openAlert() {
21+
if (isPlatformBrowser(this.platformId)) {
22+
window.alert('Yes it is!');
23+
}
24+
}
1025
}

0 commit comments

Comments
 (0)