Skip to content

Instantly share code, notes, and snippets.

@thheller
Created October 11, 2019 20:44
Show Gist options
  • Save thheller/e42d618a65ffadb0e2aa313d72600f86 to your computer and use it in GitHub Desktop.
Save thheller/e42d618a65ffadb0e2aa313d72600f86 to your computer and use it in GitHub Desktop.
(ns demo.util
(:require [clojure.java.io :as io]
[clojure.string :as str]))
(defn generate-index-html [html manifest]
(reduce
(fn [html {:keys [module-id output-name]}]
(let [js-name (str "/" (name module-id) ".js")]
(str/replace html js-name (str "/" output-name))))
html
manifest))
(comment
(generate-index-html
"<script src=\"js/main.js\"></script>"
[{:module-id :main :output-name "main.foobar.js"}]))
(defn -main [path-to-source-html path-to-js-dir]
(println
(generate-index-html
(-> path-to-source-html (io/file) (slurp))
(-> path-to-js-dir (io/file) (io/file "manifest.edn") (slurp) (read-string)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment