Permalink
Browse files

CLJS-35 & CLJS-161: serve static resources from multiple locations.

This allows same configuration to support development and production
builds.
  • Loading branch information...
1 parent 9b813c4 commit 534f704d497193908eafcb45e7b32a6542ff2e41 @neotyk neotyk committed with David Nolen May 8, 2012
Showing with 8 additions and 7 deletions.
  1. +8 −7 src/clj/cljs/repl/browser.clj
@@ -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)))
@@ -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

0 comments on commit 534f704

Please sign in to comment.