Skip to content

Commit

Permalink
CLJS-35 & CLJS-161: serve static resources from multiple locations.
Browse files Browse the repository at this point in the history
This allows same configuration to support development and production
builds.
  • Loading branch information
neotyk authored and David Nolen committed May 9, 2012
1 parent 9b813c4 commit 534f704
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/clj/cljs/repl/browser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,16 @@
(defn send-static [opts conn {path :path :as request}]
(if (and (:static-dir opts)
(not= "/favicon.ico" path))
(try
(let [path (if (= "/" path) "/index.html" path)
contents (slurp (str (:static-dir opts) path))]
(send-and-close conn 200 contents
(let [path (if (= "/" path) "/index.html" path)
st-dir (:static-dir opts)]
(if-let [local-path (seq (for [x (if (string? st-dir) [st-dir] st-dir)
:when (.exists (io/file (str x path)))]
(str x path)))]
(send-and-close conn 200 (slurp (first local-path))
(condp #(.endsWith %2 %1) path
".js" "text/javascript"
".html" "text/html"
"text/plain")))
(catch java.io.FileNotFoundException e
"text/plain"))
(send-404 conn path)))
(send-404 conn path)))

Expand Down Expand Up @@ -338,7 +339,7 @@
:optimizations :simple
:working-dir ".repl"
:serve-static true
:static-dir "."}
:static-dir ["." "out/"]}
opts)]
(do (swap! server-state
(fn [old] (assoc old :client-js
Expand Down

0 comments on commit 534f704

Please sign in to comment.