client.sh 2.2 KB

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