aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/build/client.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build/client.sh')
-rwxr-xr-xscripts/build/client.sh189
1 files changed, 52 insertions, 137 deletions
diff --git a/scripts/build/client.sh b/scripts/build/client.sh
index 644a0807f..9cd8d8cce 100755
--- a/scripts/build/client.sh
+++ b/scripts/build/client.sh
@@ -3,160 +3,75 @@
3set -eu 3set -eu
4 4
5declare -A languages 5declare -A languages
6defaultLanguage="en-US"
6 7
7pre_build_hook () { 8# Supported languages
8 mkdir "./src/pending_locale" > /dev/null || true 9languages=(
9 mv ./src/locale/angular.*.xlf "./src/pending_locale" 10 ["ar"]="ar"
10 11 ["en"]="en-US"
11 if [ ! -z ${1+x} ]; then 12 ["vi"]="vi-VN"
12 mv "./src/pending_locale/angular.$1.xlf" "./src/locale" 13 ["hu"]="hu-HU"
13 fi 14 ["th"]="th-TH"
14} 15 ["fi"]="fi-FI"
15 16 ["nl"]="nl-NL"
16post_build_hook () { 17 ["gd"]="gd"
17 mv ./src/pending_locale/* "./src/locale" 18 ["el"]="el-GR"
18 rmdir "./src/pending_locale/" 19 ["es"]="es-ES"
19} 20 ["oc"]="oc"
20 21 ["pt"]="pt-BR"
21# Previous build failed 22 ["pt-PT"]="pt-PT"
22if [ ! -f "client/src/locale/angular.fr-FR.xlf" ]; then 23 ["sv"]="sv-SE"
23 git checkout -- client/src/locale/ 24 ["pl"]="pl-PL"
24 rm -r client/src/pending_locale 25 ["ru"]="ru-RU"
25fi 26 ["zh-Hans"]="zh-Hans-CN"
27 ["zh-Hant"]="zh-Hant-TW"
28 ["fr"]="fr-FR"
29 ["ja"]="ja-JP"
30 ["eu"]="eu-ES"
31 ["ca"]="ca-ES"
32 ["cs"]="cs-CZ"
33 ["eo"]="eo"
34 ["de"]="de-DE"
35 ["it"]="it-IT"
36 ["kab"]="kab"
37)
26 38
27cd client 39cd client
28 40
29rm -rf ./dist ./compiled 41rm -rf ./dist ./compiled
30 42
31pre_build_hook
32
33additionalParams=""
34if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
35 additionalParams="--namedChunks=true --outputHashing=none"
36 export ANALYZE_BUNDLE=true
37fi
38
39if [ ! -z ${1+x} ] && [ "$1" == "--i18n" ]; then
40 additionalParams="--configuration=i18n"
41 export ANALYZE_BUNDLE=true
42fi
43
44defaultLanguage="en-US"
45npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams
46mv "./dist/$defaultLanguage/assets" "./dist"
47mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
48
49post_build_hook
50
51# Don't build other languages if --light arg is provided 43# Don't build other languages if --light arg is provided
52if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ] && [ "$1" != "--i18n" ]); then 44if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ] && [ "$1" != "--i18n" ]); then
53 if [ ! -z ${1+x} ] && [ "$1" == "--light-hu" ]; then 45 npm run ng build -- --prod --output-path "dist/build"
54 languages=(["hu"]="hu-HU")
55 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ar" ]; then
56 languages=(["ar"]="ar")
57 elif [ ! -z ${1+x} ] && [ "$1" == "--light-vi" ]; then
58 languages=(["vi"]="vi-VN")
59 elif [ ! -z ${1+x} ] && [ "$1" == "--light-kab" ]; then
60 languages=(["kab"]="kab")
61 elif [ ! -z ${1+x} ] && [ "$1" == "--light-th" ]; then
62 languages=(["th"]="th-TH")
63 elif [ ! -z ${1+x} ] && [ "$1" == "--light-fi" ]; then
64 languages=(["fi"]="fi-FI")
65 elif [ ! -z ${1+x} ] && [ "$1" == "--light-nl" ]; then
66 languages=(["nl"]="nl-NL")
67 elif [ ! -z ${1+x} ] && [ "$1" == "--light-gd" ]; then
68 languages=(["gd"]="gd")
69 elif [ ! -z ${1+x} ] && [ "$1" == "--light-el" ]; then
70 languages=(["el"]="el-GR")
71 elif [ ! -z ${1+x} ] && [ "$1" == "--light-es" ]; then
72 languages=(["es"]="es-ES")
73 elif [ ! -z ${1+x} ] && [ "$1" == "--light-oc" ]; then
74 languages=(["oc"]="oc")
75 elif [ ! -z ${1+x} ] && [ "$1" == "--light-pt" ]; then
76 languages=(["pt"]="pt-BR")
77 elif [ ! -z ${1+x} ] && [ "$1" == "--light-pt-PT" ]; then
78 languages=(["pt-PT"]="pt-PT")
79 elif [ ! -z ${1+x} ] && [ "$1" == "--light-sv" ]; then
80 languages=(["sv"]="sv-SE")
81 elif [ ! -z ${1+x} ] && [ "$1" == "--light-pl" ]; then
82 languages=(["pl"]="pl-PL")
83 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ru" ]; then
84 languages=(["ru"]="ru-RU")
85 elif [ ! -z ${1+x} ] && [ "$1" == "--light-zh-Hans" ]; then
86 languages=(["zh-Hans"]="zh-Hans-CN")
87 elif [ ! -z ${1+x} ] && [ "$1" == "--light-zh-Hant" ]; then
88 languages=(["zh-Hant"]="zh-Hant-TW")
89 elif [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then
90 languages=(["fr"]="fr-FR")
91 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ja" ]; then
92 languages=(["ja"]="ja-JP")
93 elif [ ! -z ${1+x} ] && [ "$1" == "--light-eu" ]; then
94 languages=(["eu"]="eu-ES")
95 elif [ ! -z ${1+x} ] && [ "$1" == "--light-ca" ]; then
96 languages=(["ca"]="ca-ES")
97 elif [ ! -z ${1+x} ] && [ "$1" == "--light-cs" ]; then
98 languages=(["cs"]="cs-CZ")
99 elif [ ! -z ${1+x} ] && [ "$1" == "--light-eo" ]; then
100 languages=(["eo"]="eo")
101 elif [ ! -z ${1+x} ] && [ "$1" == "--light-de" ]; then
102 languages=(["de"]="de-DE")
103 elif [ ! -z ${1+x} ] && [ "$1" == "--light-it" ]; then
104 languages=(["it"]="it-IT")
105 else
106 # Supported languages
107 languages=(
108 ["ar"]="ar"
109 ["vi"]="vi-VN"
110 ["hu"]="hu-HU"
111 ["th"]="th-TH"
112 ["fi"]="fi-FI"
113 ["nl"]="nl-NL"
114 ["gd"]="gd"
115 ["el"]="el-GR"
116 ["es"]="es-ES"
117 ["oc"]="oc"
118 ["pt"]="pt-BR"
119 ["pt-PT"]="pt-PT"
120 ["sv"]="sv-SE"
121 ["pl"]="pl-PL"
122 ["ru"]="ru-RU"
123 ["zh-Hans"]="zh-Hans-CN"
124 ["zh-Hant"]="zh-Hant-TW"
125 ["fr"]="fr-FR"
126 ["ja"]="ja-JP"
127 ["eu"]="eu-ES"
128 ["ca"]="ca-ES"
129 ["cs"]="cs-CZ"
130 ["eo"]="eo"
131 ["de"]="de-DE"
132 ["it"]="it-IT"
133 ["kab"]="kab"
134 )
135 fi
136 46
137 for key in "${!languages[@]}"; do 47 for key in "${!languages[@]}"; do
138 lang=${languages[$key]} 48 lang=${languages[$key]}
139 49
140 # TODO: remove when the project will use runtime translations 50 mv "dist/build/$key" "dist/$lang"
141 pre_build_hook "$lang"
142 51
143 npm run ng build -- --prod --configuration="$lang" --output-path "dist/build" 52 if [ "$lang" != "en-US" ]; then
53 # Do not duplicate assets
54 rm -r "./dist/$lang/assets"
55 fi
56 done
144 57
145 # If --localize is not used 58 mv "./dist/$defaultLanguage/assets" "./dist"
146 mv "dist/build/$key" "dist/$lang" 59 mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
147 rmdir "dist/build"
148 60
149 # If --localize is used 61 rmdir "dist/build"
150 # if [ ! "$lang" = "$key" ]; then 62else
151 # mv "dist/$key" "dist/$lang" 63 additionalParams=""
152 # fi 64 if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
65 additionalParams="--namedChunks=true --outputHashing=none"
66 export ANALYZE_BUNDLE=true
67 fi
153 68
154 # Do not duplicate assets 69 if [ ! -z ${1+x} ] && [ "$1" == "--i18n" ]; then
155 rm -r "./dist/$lang/assets" 70 additionalParams="--configuration=i18n"
71 export ANALYZE_BUNDLE=true
72 fi
156 73
157 # TODO: remove when the project will use runtime translations 74 npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams
158 post_build_hook
159 done
160fi 75fi
161 76
162cd ../ && npm run build:embed && cd client/ 77cd ../ && npm run build:embed && cd client/