X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fbuild%2Fclient.sh;h=0e7925be5c29c9a153a647ae9b9948c8abf3f479;hb=1d22d2514f7be14d51ed2ab78e13df5da2646546;hp=ee647bb991d7a694692c92f89a82ec89c7761f98;hpb=dafbad0caef873bc01c0ce43748b01641d1d8795;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/build/client.sh b/scripts/build/client.sh index ee647bb99..0e7925be5 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh @@ -2,67 +2,75 @@ set -eu -pre_build_hook () { - mkdir "./src/pending_locale" > /dev/null || true - mv ./src/locale/angular.*.xlf "./src/pending_locale" - - if [ ! -z ${1+x} ]; then - mv "./src/pending_locale/angular.$1.xlf" "./src/locale" - fi -} - -post_build_hook () { - mv ./src/pending_locale/* "./src/locale" - rmdir "./src/pending_locale/" -} +declare -A languages +defaultLanguage="en-US" -# Previous build failed -if [ ! -f "client/src/locale/angular.fr-FR.xlf" ]; then - git checkout -- client/src/locale/ - rm -r client/src/pending_locale -fi +# Supported languages +languages=( + ["ar"]="ar" + ["en"]="en-US" + ["vi"]="vi-VN" + ["hu"]="hu-HU" + ["th"]="th-TH" + ["fi"]="fi-FI" + ["nl"]="nl-NL" + ["gd"]="gd" + ["el"]="el-GR" + ["es"]="es-ES" + ["oc"]="oc" + ["pt"]="pt-BR" + ["pt-PT"]="pt-PT" + ["sv"]="sv-SE" + ["pl"]="pl-PL" + ["ru"]="ru-RU" + ["zh-Hans"]="zh-Hans-CN" + ["zh-Hant"]="zh-Hant-TW" + ["fr"]="fr-FR" + ["ja"]="ja-JP" + ["eu"]="eu-ES" + ["ca"]="ca-ES" + ["gl"]="gl-ES" + ["cs"]="cs-CZ" + ["eo"]="eo" + ["de"]="de-DE" + ["it"]="it-IT" + ["kab"]="kab" +) cd client rm -rf ./dist ./compiled -pre_build_hook +# Don't build other languages if --light arg is provided +if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); then + npm run ng build -- --prod --output-path "dist/build" -defaultLanguage="en-US" -npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json -mv "./dist/$defaultLanguage/assets" "./dist" -mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest" + for key in "${!languages[@]}"; do + lang=${languages[$key]} -post_build_hook + mv "dist/build/$key" "dist/$lang" -# Don't build other languages if --light arg is provided -if [ -z ${1+x} ] || [ "$1" != "--light" ]; then - if [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then - languages=("fr-FR") - else - # Supported languages - languages=( - "hu-HU" "th-TH" - "fi-FI" "nl-NL" "gd" "el-GR" "es-ES" "oc" "pt-BR" "pt-PT" "sv-SE" "pl-PL" "ru-RU" "zh-Hans-CN" "zh-Hant-TW" - "fr-FR" "ja-JP" "eu-ES" "ca-ES" "cs-CZ" "eo" "de-DE" "it-IT" - ) - fi - - for lang in "${languages[@]}"; do - # TODO: remove when the project will use runtime translations - pre_build_hook "$lang" + if [ "$lang" != "en-US" ]; then + # Do not duplicate assets + rm -r "./dist/$lang/assets" + fi + done - npm run ng build -- --prod --i18n-file "./src/locale/angular.$lang.xlf" --i18n-format xlf --i18n-locale "$lang" \ - --output-path "dist/$lang/" --deploy-url "/client/$lang/" + mv "./dist/$defaultLanguage/assets" "./dist" - # Do not duplicate assets - rm -r "./dist/$lang/assets" + rmdir "dist/build" +else + additionalParams="" + if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then + additionalParams="--namedChunks=true --outputHashing=none" + export ANALYZE_BUNDLE=true + fi - # TODO: remove when the project will use runtime translations - post_build_hook - done + npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams fi +cp "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest" + cd ../ && npm run build:embed && cd client/ # Copy runtime locales