|
177 | 177 |
|
178 | 178 | (defn send-static |
179 | 179 | [{path :path :as request} conn |
180 | | - ;; NOTE: :output-to and :output-dir are available here because cljs.cli |
181 | | - ;; does this - should maybe rethink that, we need a better way to supply |
182 | | - ;; the main JS file to load because it might not be compiler options :output-to |
183 | | - ;; i.e. bundler step |
184 | | - {:keys [static-dir output-to output-dir host port gzip?] :or {output-dir "out"} :as opts}] |
| 180 | + {:keys [static-dir output-dir host port gzip?] :or {output-dir "out"} :as opts}] |
185 | 181 | (let [output-dir (when-not (.isAbsolute (io/file output-dir)) output-dir)] |
186 | 182 | (if (and static-dir (not= "/favicon.ico" path)) |
187 | 183 | (let [path (if (= "/" path) "/index.html" path) |
|
208 | 204 | encoding (mime-type->encoding mime-type "UTF-8")] |
209 | 205 | (server/send-and-close conn 200 (slurp local-path :encoding encoding) |
210 | 206 | mime-type encoding (and gzip? (= "text/javascript" mime-type)))) |
| 207 | + |
211 | 208 | ;; "/index.html" doesn't exist, provide our own |
212 | 209 | (= path "/index.html") |
213 | 210 | (server/send-and-close conn 200 |
214 | | - (default-index (or output-to (str output-dir "/main.js"))) |
| 211 | + (default-index (str output-dir "/main.js")) |
215 | 212 | "text/html" "UTF-8") |
| 213 | + |
| 214 | + ;; "/main.js" doesn't exist, provide our own |
216 | 215 | (= path (cond->> "/main.js" output-dir (str "/" output-dir ))) |
217 | 216 | (let [closure-defines (-> `{"goog.json.USE_NATIVE_JSON" true |
218 | 217 | clojure.browser.repl/HOST ~host |
|
230 | 229 | "document.write('<script src=\"" output-dir "/brepl_deps.js\"></script>');\n" |
231 | 230 | "document.write('<script>goog.require(\"clojure.browser.repl.preload\");</script>');\n") |
232 | 231 | "text/javascript" "UTF-8")) |
| 232 | + |
233 | 233 | :else (server/send-404 conn path))) |
234 | 234 | (server/send-404 conn path)))) |
235 | 235 |
|
|
0 commit comments