I'm new to Clojure and I'm trying to setup a development environment where I can dynamically load my web project files using ring-server and cljsbuild
i have the following snippet in my project file
:ring {
:handler cjohansen-no.web/app
;;:auto-refresh true
;;:auto-reload? true
;;:reload-paths ["resources","src"]
;;:refresh-paths ["resources","src"]
}
:aliases {
"start-server" ["ring" "server-headless"]
"build-site" ["run" "-m" "cjohansen-no.web/export"]
"build-html" ["run" "-m" "cjohansen-no.web/export-pages"]
"build-js" ["cljsbuild" "auto" "dev"]
"build-web" ["do" ["build-site"] ["build-js"]]
"build-dev" ["pdo" ["build-web"] ["start-server"] ["auto" "build-html"]]
}
:source-paths ["src"]
:test-paths ["test/cjohansen_no" "test/cljs" "spec"]
:clean-targets [:target-path "./build/js/out"
:compile-path "classes"
:output-paths "./build/js/output"
"build/js/main.js.map"
]
:main cjohansen-no.web
:clean-non-project-classes true
:figwheel {
;;:server-port 3000
:css-dirs ["resources/public/css"]
:reload-clj-files {:clj true :cljc false}
:ring-handler cjohansen-no.web/app
:repl false
}
:cljsbuild {
:builds [
{
;; :notify-command ["growlnotify" "-m"]
:id "dev"
:source-paths ["src/cljs"]
:figwheel {
:websocket-host :js-client-host
:autoload false
:reload-dependents true
:debug true
}
:compiler {
:main scripts.core
:output-to "resources/public/js/main.js"
:output-dir "resources/public/js/out"
:optimizations :none
:source-map true
:source-map-timestamp true
:recompile-dependents false
:pretty-print true
:asset-path "js/out"
;;:notify-command ["bin/phantomjs" "bin/speclj.js" "resources/public/js/main.js"]
}
},
....
}
:profiles {
:dev {
:dependencies [
;;[figwheel "0.5.4-7"]
]
:plugins [
[lein-pdo "0.1.1"]
[lein-ring "0.9.7"]
[lein-cljsbuild "1.1.3"]
[lein-figwheel "0.5.4-7"]
]
}
I use this snippet to run my server
(def app (->
(stasis/serve-pages get-pages)
(optimus/wrap get-assets optimizations/all serve-live-assets)
;;(wrap-cljsbuild "/js/" cljsbuild)
wrap-content-type
;; wrap-reload
wrap-utf-8))
I'm loading my assets using Optimus
(defn get-assets []
(concat (assets/load-bundle "public" "styles.css" [#"css/.+\.css$"])
(assets/load-assets "public" [#"img/.*" "/questions.json"])
(assets/load-bundle "public" "main.js" [#"js/.+\.js"])
))
when I run lein with-profile dev pdf start-server, cljsbuild auto
and bring up my website the js files and its dependants as compiled by the "dev" build takes FOREVER to complete loading. Why is the ring server so slow?
Should I be referencing the build files in this manner? should i bundle it into one file?
The profile used is for development purposes.