Skip to content

Commit e42bf6d

Browse files
hollowaykeanhoJeanShuralyovcorygalyna
committed
root: upgraded angular to use SSG and SSR + PWA capabilities
The existing Angular workspace is severely outdated and confusing. Since Angular 17 released SSG, SSR, and PWA, we should implement them. Hence, let's do this. This patch upgrades angular to use SSG and SSR + PWA capabilities in root repository. Co-authored-by: Shuralyov, Jean <jean.shuralyov@proton.me> Co-authored-by: Galyna, Cory <cory.galyna@gmail.com> Co-authored-by: (Holloway) Chew, Kean Ho <me@hollowaykeanho.com> Signed-off-by: (Holloway) Chew, Kean Ho <me@hollowaykeanho.com>
1 parent 6287871 commit e42bf6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1078
-269
lines changed

srcANGULAR/.ci/build_unix-any.sh renamed to Angular/.ci/build_unix-any.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ${PROJECT_SKU}-docs_any-any
3333
"
3434

3535

36+
FS_Remake_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}"
3637

3738

3839
I18N_Activate_Environment
@@ -56,6 +57,19 @@ fi
5657

5758

5859

60+
___source="${PROJECT_PATH_ROOT}/${PROJECT_ANGULAR}/dist/browser"
61+
___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}"
62+
I18N_Export "$___dest"
63+
FS_Make_Directory "$___dest"
64+
FS_Copy_All "${___source}/" "$___dest"
65+
if [ $? -ne 0 ]; then
66+
I18N_Export_Failed
67+
return 1
68+
fi
69+
70+
71+
72+
5973
# placeholding flag files
6074
old_IFS="$IFS"
6175
while IFS="" read -r __line || [ -n "$__line" ]; do

srcANGULAR/.ci/build_windows-any.ps1 renamed to Angular/.ci/build_windows-any.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $__placeholders = @(
3232
)
3333

3434

35+
$null = FS-Remake-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}"
3536

3637

3738
$null = I18N-Activate-Environment
@@ -56,6 +57,19 @@ if ($___process -ne 0) {
5657

5758

5859

60+
$___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_ANGULAR}\dist\browser"
61+
$___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}"
62+
$null = I18N-Export "${___dest}"
63+
$null = FS-Make-Directory "${___dest}"
64+
$___process = FS-Copy-All "${___source}\" "${___dest}"
65+
if ($___process -ne 0) {
66+
$null = I18N-Export-Failed
67+
return 1
68+
}
69+
70+
71+
72+
5973
# placeholding flag files
6074
foreach ($__line in $__placeholders) {
6175
if ($(STRINGS-Is-Empty "${__line}") -eq 0) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Angular/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# AutomataCI Static Site Generator Angular Setup
2+
3+
This document is mainly for Angular developer to understand what is going on
4+
with the organization here. Most of the resources are the same.
5+
6+
7+
8+
9+
## Directory Structures
10+
11+
Unlike what was recommended by Angular, AutomataCI prepares 2 separate
12+
components directories:
13+
14+
1. `contents/` - organize the pages
15+
2. `services/` - where your libraries and components stays
16+
17+
The `contents/` structures the website page hirarchy and imports the `services/`
18+
libraries to construct the page.
19+
20+
21+
22+
23+
## Server-Side Rendering (SSR) or Static Site Generation (SSG) First
24+
25+
There is a high chance this project is likely being used to generate JAM Stack.
26+
Hence, AutomataCI prioritizes the SSR and SSG (pre-rendering) facilities.
27+
28+
29+
30+
31+
## Setting website Base URL
32+
33+
To set the Base URL, make sure you update the `baseHref` and `deployUrl` data
34+
inside `angular.json`:
35+
36+
```
37+
diff --git a/angular/angular.json b/angular/angular.json
38+
index 5379d9e..fb2e8fa 100644
39+
--- a/angular/angular.json
40+
+++ b/angular/angular.json
41+
@@ -46,6 +46,8 @@
42+
},
43+
"configurations": {
44+
"production": {
45+
+ "baseHref": "https://www.example.com/",
46+
+ "deployUrl": "https://www.example.com/",
47+
"budgets": [
48+
{
49+
"type": "initial",
50+
```
51+
52+
Then make sure you edit `assets/CNAME` and add only the domain name inside. This
53+
is for GitHub or GitLab authentication use.
54+
55+
Then update the `assets/manifest.webmanifest` for PWA settings. Specifically,
56+
look for `start_url` and etc.
57+
58+
59+
60+
61+
## For development
62+
63+
Everything is the same as Angular: `$ ng serve`
64+
65+
66+
67+
68+
## For Tests
69+
70+
Everything is the same as Angular: `$ ng test` OR `$ ng e2e`
71+
72+
73+
74+
75+
## For Production
76+
77+
Everything is the same as Angular: `$ ng build`
78+
79+
For full automation, use: `$ ./automataCI/ci.sh.ps1 build`

srcANGULAR/angular.json renamed to Angular/angular.json

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,47 @@
77
"projectType": "application",
88
"schematics": {},
99
"root": "",
10-
"sourceRoot": "src",
10+
"sourceRoot": ".",
1111
"prefix": "app",
1212
"architect": {
1313
"build": {
1414
"builder": "@angular-devkit/build-angular:application",
1515
"options": {
16+
"crossOrigin": "anonymous",
1617
"outputPath": {
17-
"base": "../public"
18+
"base": "dist",
19+
"browser": "browser",
20+
"server": "server"
1821
},
19-
"index": "src/index.html",
22+
"index": "app.html",
2023
"polyfills": [
2124
"zone.js"
2225
],
2326
"tsConfig": "tsconfig.app.json",
24-
"assets": [
25-
"src/favicon.ico",
26-
"src/assets"
27-
],
27+
"assets": [{
28+
"glob": "**/*",
29+
"input": "assets",
30+
"output": "."
31+
}],
2832
"styles": [
29-
"src/styles.css"
33+
"app.css"
34+
],
35+
"scripts": [
36+
"app.js"
3037
],
31-
"scripts": [],
32-
"browser": "src/main.ts"
38+
"browser": "main.ts",
39+
"server": "main.server.ts",
40+
"prerender": {
41+
"routesFile": "prerender-routes.txt"
42+
},
43+
"ssr": {
44+
"entry": "server.ts"
45+
}
3346
},
3447
"configurations": {
3548
"production": {
49+
"baseHref": "https://www.example.com/",
50+
"deployUrl": "https://www.example.com/",
3651
"budgets": [
3752
{
3853
"type": "initial",
@@ -45,7 +60,8 @@
4560
"maximumError": "4kb"
4661
}
4762
],
48-
"outputHashing": "all"
63+
"outputHashing": "all",
64+
"serviceWorker": "ngsw-config.json"
4965
},
5066
"development": {
5167
"optimization": false,
@@ -83,14 +99,17 @@
8399
"zone.js/testing"
84100
],
85101
"tsConfig": "tsconfig.spec.json",
86-
"assets": [
87-
"src/favicon.ico",
88-
"src/assets"
89-
],
102+
"assets": [{
103+
"glob": "**/*",
104+
"input": "assets",
105+
"output": "."
106+
}],
90107
"styles": [
91-
"src/styles.css"
108+
"app.css"
92109
],
93-
"scripts": []
110+
"scripts": [
111+
"app.js"
112+
]
94113
}
95114
}
96115
}

0 commit comments

Comments
 (0)