hooks.clj 808 B

123456789101112131415161718192021222324252627282930
  1. (ns hooks
  2. (:require
  3. [babashka.fs :as fs]
  4. [babashka.process :as proc]))
  5. (defn copy-assets
  6. {:shadow.build/stage :configure}
  7. [build-state {:keys [public-dir assets]}]
  8. (doseq [[src dest] assets]
  9. ((if (fs/directory? src) fs/copy-tree fs/copy)
  10. src
  11. (str public-dir "/" dest)
  12. {:replace-existing true
  13. :copy-attributes true
  14. :nofollow-links true}))
  15. build-state)
  16. (defn webpack-watch
  17. {:shadow.build/stage :configure}
  18. [build-state]
  19. (proc/process {:extra-env {"NODE_ENV" "development"} :out *out* :err :out}
  20. "./node_modules/.bin/webpack --watch")
  21. build-state)
  22. (defn webpack-release
  23. {:shadow.build/stage :configure}
  24. [build-state]
  25. (proc/shell {:extra-env {"NODE_ENV" "production"}}
  26. "./node_modules/.bin/webpack")
  27. build-state)