Created
October 11, 2019 20:44
-
-
Save thheller/e42d618a65ffadb0e2aa313d72600f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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