build-assets.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -e
  3. # build css and js files using esbuild
  4. # we don't install esbuild as a node npm package as we have simple needs.
  5. # we instead download a built executable of it, check this URL
  6. # <https://esbuild.github.io/getting-started/#other-ways-to-install>
  7. if hash ./esbuild 2>/dev/null; then
  8. echo "esbuild available! let's proceed..."
  9. echo ""
  10. # styles.css
  11. ./esbuild static/css/styles.css \
  12. --entry-names=[name]-[hash] \
  13. --bundle \
  14. --loader:.woff=file \
  15. --loader:.woff2=file \
  16. --asset-names=fonts/[name] \
  17. --target=chrome58,firefox57,safari11,edge16 \
  18. --outdir=static/dist
  19. # product.js
  20. ./esbuild static/js/product.js \
  21. --bundle \
  22. --entry-names=[name]-[hash] \
  23. --target=chrome58,firefox57,safari11,edge16 \
  24. --splitting \
  25. --format=esm \
  26. --outdir=static/dist
  27. # checkout.js
  28. ./esbuild static/js/checkout.js \
  29. --bundle \
  30. --entry-names=[name]-[hash] \
  31. --target=chrome58,firefox57,safari11,edge16 \
  32. --splitting \
  33. --format=esm \
  34. --outdir=static/dist
  35. echo ""
  36. echo "esbuild is done."
  37. else
  38. echo "Please download a build of esbuild from here"
  39. echo "https://esbuild.github.io/getting-started/#other-ways-to-install"
  40. echo "and place it in the root dir of this repo."
  41. fi