client.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. set -eu
  3. declare -A languages
  4. defaultLanguage="en-US"
  5. # Supported languages
  6. languages=(
  7. ["ar"]="ar"
  8. ["en"]="en-US"
  9. ["vi"]="vi-VN"
  10. ["hu"]="hu-HU"
  11. ["th"]="th-TH"
  12. ["fi"]="fi-FI"
  13. ["nl"]="nl-NL"
  14. ["gd"]="gd"
  15. ["el"]="el-GR"
  16. ["es"]="es-ES"
  17. ["oc"]="oc"
  18. ["pt"]="pt-BR"
  19. ["pt-PT"]="pt-PT"
  20. ["sv"]="sv-SE"
  21. ["pl"]="pl-PL"
  22. ["ru"]="ru-RU"
  23. ["zh-Hans"]="zh-Hans-CN"
  24. ["zh-Hant"]="zh-Hant-TW"
  25. ["fr"]="fr-FR"
  26. ["ja"]="ja-JP"
  27. ["eu"]="eu-ES"
  28. ["ca"]="ca-ES"
  29. ["gl"]="gl-ES"
  30. ["cs"]="cs-CZ"
  31. ["eo"]="eo"
  32. ["de"]="de-DE"
  33. ["it"]="it-IT"
  34. ["kab"]="kab"
  35. )
  36. cd client
  37. rm -rf ./dist ./compiled
  38. # Don't build other languages if --light arg is provided
  39. if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); then
  40. npm run ng build -- --prod --output-path "dist/build"
  41. for key in "${!languages[@]}"; do
  42. lang=${languages[$key]}
  43. mv "dist/build/$key" "dist/$lang"
  44. if [ "$lang" != "en-US" ]; then
  45. # Do not duplicate assets
  46. rm -r "./dist/$lang/assets"
  47. fi
  48. done
  49. mv "./dist/$defaultLanguage/assets" "./dist"
  50. rmdir "dist/build"
  51. else
  52. additionalParams=""
  53. if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
  54. additionalParams="--namedChunks=true --outputHashing=none"
  55. export ANALYZE_BUNDLE=true
  56. fi
  57. npm run ng build -- --localize=false --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams
  58. fi
  59. mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
  60. mv "./dist/$defaultLanguage/ngsw-worker.js" "./dist/"
  61. cd ../ && npm run build:embed && cd client/
  62. # Copy runtime locales
  63. cp -r "./src/locale" "./dist/locale"