]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/build/client.sh
Fix sha fallback
[github/Chocobozzz/PeerTube.git] / scripts / build / client.sh
CommitLineData
10e63b68 1#!/bin/bash
b20b5fed 2
0e4ffb4b
LA
3set -eu
4
361dcebc 5declare -A languages
66357162 6defaultLanguage="en-US"
361dcebc 7
66357162
C
8# Supported languages
9languages=(
10 ["ar"]="ar"
11 ["en"]="en-US"
12 ["vi"]="vi-VN"
13 ["hu"]="hu-HU"
14 ["th"]="th-TH"
15 ["fi"]="fi-FI"
16 ["nl"]="nl-NL"
17 ["gd"]="gd"
18 ["el"]="el-GR"
19 ["es"]="es-ES"
20 ["oc"]="oc"
21 ["pt"]="pt-BR"
22 ["pt-PT"]="pt-PT"
23 ["sv"]="sv-SE"
24 ["pl"]="pl-PL"
25 ["ru"]="ru-RU"
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"
c7444546 32 ["gl"]="gl-ES"
66357162
C
33 ["cs"]="cs-CZ"
34 ["eo"]="eo"
35 ["de"]="de-DE"
36 ["it"]="it-IT"
f45aa01a 37 ["sq"]="sq"
66357162
C
38 ["kab"]="kab"
39)
95d51135 40
0e4ffb4b 41cd client
b20b5fed 42
29b7426c 43rm -rf ./dist
d61e8153 44
e032aec9 45# Don't build other languages if --light arg is provided
ae48a71d 46if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); then
29f148a6
C
47 additionalParams=""
48 if [ ! -z ${1+x} ] && [ "$1" == "--source-map" ]; then
49 additionalParams="--sourceMap=true"
50 fi
51
13c749c1 52 node --max_old_space_size=8192 node_modules/.bin/ng build --configuration production --output-path "dist/build" $additionalParams
e032aec9 53
361dcebc
C
54 for key in "${!languages[@]}"; do
55 lang=${languages[$key]}
56
66357162 57 mv "dist/build/$key" "dist/$lang"
d73c9888 58
66357162
C
59 if [ "$lang" != "en-US" ]; then
60 # Do not duplicate assets
61 rm -r "./dist/$lang/assets"
62 fi
63 done
361dcebc 64
66357162 65 mv "./dist/$defaultLanguage/assets" "./dist"
2779f29a 66
66357162
C
67 rmdir "dist/build"
68else
69 additionalParams=""
70 if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
71 additionalParams="--namedChunks=true --outputHashing=none"
72 export ANALYZE_BUNDLE=true
73 fi
e032aec9 74
13c749c1 75 node --max_old_space_size=8192 node_modules/.bin/ng build --localize=false --output-path "dist/$defaultLanguage/" \
662351e6 76 --deploy-url "/client/$defaultLanguage/" --configuration production --stats-json $additionalParams
e032aec9 77fi
989e526a 78
1d22d251 79cp "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
dfdd158a 80
a3b5e78a 81cd ../ && npm run build:embed && cd client/
989e526a 82
96bb360d 83# Copy runtime locales
350131cb 84cp -r "./src/locale" "./dist/locale"