Skip to content
Browse files

Move repeated application root string to the configuration map.

Fixes broken advanced compilation.
  • Loading branch information...
1 parent ff54b18 commit caa0090dff7816d6318206d129085dd9de855acd @brentonashworth brentonashworth committed Dec 14, 2011
4 src/app/clj/one/sample/config.clj
@@ -8,7 +8,9 @@
(html/substitute (html/html-snippet ""))))
(def ^{:doc "Configuration for the sample application."}
- config {:top-level-package "one/sample"
+ config {:src-root "src"
+ :app-root "src/app/cljs"
+ :top-level-package "one"
:js "public/javascripts"
:dev-js-file-name "main.js"
:prod-js-file-name "mainp.js"
2 src/app/clj/one/sample/dev_server.clj
@@ -52,7 +52,7 @@
(handler request))))
(def ^:private app (-> app-routes
- (reload/watch-cljs "src" config)
+ (reload/watch-cljs config)
(wrap-file "public")
13 src/lib/clj/one/reload.clj
@@ -31,28 +31,27 @@
[dir k]
(let [files (filter #(.isFile %) (into (descendants-ending-with dir ".cljs")
(file-seq (io/file "templates"))))]
- (pr-str files)
(any-modified k files)))
(defn watch-cljs
"Ring middleware which watches dir for changes to ClojureScript
source files and template HTML files. When changes are detected,
recompiles only the ClojureScript and template files (not the
Clojure files) using a build configuration derived from config."
- [handler dir config]
+ [handler config]
(fn [request]
(let [k (:uri request)
- ts (any-modified-cljs dir k)]
+ ts (any-modified-cljs (:src-root config) k)]
(when ts
(swap! last-compile assoc k ts)
(let [build-opts (cljs-build-opts config)]
(doseq [file (file-seq (io/file (str (:output-dir build-opts) "/"
(:top-level-package config))))]
(.setLastModified file 0))
- (build dir (if (= (:uri request) "/production")
- (assoc build-opts :optimizations :advanced
- :output-to (production-js config))
- build-opts)))))
+ (build (:app-root config) (if (= (:uri request) "/production")
+ (assoc build-opts :optimizations :advanced
+ :output-to (production-js config))
+ build-opts)))))
(handler request)))
(defn- any-modified-clj
6 src/lib/clj/one/tools.clj
@@ -9,7 +9,7 @@
"Emit both a JavaScript file containing the compiled ClojureScript
application and the host HTML page."
- (build "src/app/cljs" (assoc (cljs-build-opts config)
- :optimizations :advanced
- :output-to (str "out/" (production-js config))))
+ (build (:app-root config) (assoc (cljs-build-opts config)
+ :optimizations :advanced
+ :output-to (str "out/" (production-js config))))
(spit "out/public/index.html" (application-host config :production)))

0 comments on commit caa0090

Please sign in to comment.
Something went wrong with that request. Please try again.