styles.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # ==============================================================================
  3. # FUNCTIONS - START
  4. # ==============================================================================
  5. run_it()
  6. {
  7. local _name="${1-styles}"
  8. local _dir="${2-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
  9. local _target="${_dir%/*}" # deleted slash
  10. local _src="${_target%scripts}/src/scss/custom/${_name}.scss" # input
  11. local _dest="${_target%scripts}/build/css/${_name}.css" # output
  12. local _options="${3---sourcemap=none}"
  13. # ----------------------------------------------------------------------------
  14. local _dest_dir
  15. _dest_dir="$(dirname "${_dest}")"
  16. if [ ! -d "${_dest_dir}" ]; then
  17. mkdir -p "${_dest_dir}"
  18. fi
  19. # ----------------------------------------------------------------------------
  20. sass "${_src}" "${_dest}" "${_options}" -t expanded
  21. }
  22. run_compress()
  23. {
  24. local _name="${1-styles}"
  25. local _dir="${2-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
  26. local _target="${_dir%/*}" # deleted slash
  27. local _src="${_target%scripts}/src/scss/custom/${_name}.scss" # input
  28. local _dest="${_target%scripts}/build/css/${_name}.min.css" # output
  29. local _options="${3---sourcemap=none}"
  30. # ----------------------------------------------------------------------------
  31. local _dest_dir
  32. _dest_dir="$(dirname "${_dest}")"
  33. if [ ! -d "${_dest_dir}" ]; then
  34. mkdir -p "${_dest_dir}"
  35. fi
  36. # ----------------------------------------------------------------------------
  37. sass "${_src}" "${_dest}" "${_options}" -t compressed
  38. }
  39. # ==============================================================================
  40. # EXECUTION - START
  41. # ==============================================================================
  42. run_it "$@" && run_compress "$@"
  43. # ==============================================================================
  44. # EXECUTION - END
  45. # ==============================================================================