client.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. set -eu
  3. pre_build_hook () {
  4. mkdir "./src/locale/pending_target/" > /dev/null || true
  5. mv ./src/locale/target/angular_*.xml "./src/locale/pending_target"
  6. if [ ! -z ${1+x} ]; then
  7. mv "./src/locale/pending_target/angular_$1.xml" "./src/locale/target"
  8. fi
  9. }
  10. post_build_hook () {
  11. mv ./src/locale/pending_target/* "./src/locale/target/"
  12. rmdir "./src/locale/pending_target/"
  13. }
  14. # Previous build failed
  15. if [ ! -f client/src/locale/target/angular_fr_FR.xml ]; then
  16. git checkout -- client/src/locale/target/
  17. rm -r client/src/locale/pending_target/
  18. fi
  19. cd client
  20. rm -rf ./dist ./compiled
  21. pre_build_hook
  22. defaultLanguage="en_US"
  23. npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json
  24. mv "./dist/$defaultLanguage/assets" "./dist"
  25. mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
  26. post_build_hook
  27. # Don't build other languages if --light arg is provided
  28. if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
  29. if [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then
  30. languages=("fr_FR")
  31. else
  32. # Supported languages
  33. languages=("nl_NL" "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")
  34. fi
  35. for lang in "${languages[@]}"; do
  36. # TODO: remove when the project will use runtime translations
  37. pre_build_hook "$lang"
  38. npm run ng build -- --prod --i18n-file "./src/locale/target/angular_$lang.xml" --i18n-format xlf --i18n-locale "$lang" \
  39. --output-path "dist/$lang/" --deploy-url "/client/$lang/"
  40. # Do not duplicate assets
  41. rm -r "./dist/$lang/assets"
  42. # TODO: remove when the project will use runtime translations
  43. post_build_hook
  44. done
  45. fi
  46. NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json"
  47. # Copy runtime locales
  48. cp -r "./src/locale/target" "./dist/locale"