From d99709cf2c9b6d7868729c5946a79da01a9d326d Mon Sep 17 00:00:00 2001 From: Connie Leung Date: Mon, 4 Mar 2024 00:09:14 +0800 Subject: [PATCH] chore: generate files to deploy to github page --- .gitignore | 1 + angular.json | 6 ++++-- deploy-github-page.sh | 17 +++++++++++++++++ generate-config-file.sh | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 deploy-github-page.sh create mode 100755 generate-config-file.sh diff --git a/.gitignore b/.gitignore index 0c96482..3d58dba 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ testem.log Thumbs.db src/assets/config.json +docs diff --git a/angular.json b/angular.json index 0195b9f..1c9a4f4 100644 --- a/angular.json +++ b/angular.json @@ -10,7 +10,8 @@ "style": "scss", "inlineStyle": true, "inlineTemplate": true, - "skipTests": true + "skipTests": true, + "changeDetection": "OnPush" } }, "root": "", @@ -54,7 +55,8 @@ "maximumError": "4kb" } ], - "outputHashing": "all" + "outputHashing": "all", + "baseHref": "https://railsstudent.github.io/ng-ai-google-demo/" }, "development": { "buildOptimizer": false, diff --git a/deploy-github-page.sh b/deploy-github-page.sh new file mode 100755 index 0000000..0f39035 --- /dev/null +++ b/deploy-github-page.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +./generate-config-file.sh $1 + +echo "delete docs" +rm -rf docs +echo "build project starts" +ng build --output-path docs/ +cp ./docs/browser/index.html ./docs/browser/404.html +cp ./docs/browser/* ./docs +rm -rf ./docs/browser +echo 'build project finishes' diff --git a/generate-config-file.sh b/generate-config-file.sh new file mode 100755 index 0000000..e1e3ec4 --- /dev/null +++ b/generate-config-file.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +apiConfig='{ + "apiKey": "'"$1"'" +}' + +outputFile='src/assets/config.json' +echo $apiConfig > $outputFile +