2
1

client.sh 2.1 KB

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