This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-09
Channels
- # beginners (140)
- # boot (163)
- # cider (43)
- # cljs-dev (50)
- # cljsjs (5)
- # cljsrn (38)
- # clojure (152)
- # clojure-austria (10)
- # clojure-berlin (9)
- # clojure-dev (11)
- # clojure-japan (1)
- # clojure-miami (2)
- # clojure-russia (147)
- # clojure-sg (12)
- # clojurescript (244)
- # code-reviews (3)
- # cursive (104)
- # data-science (5)
- # datavis (15)
- # datomic (35)
- # editors (4)
- # hoplon (1)
- # ldnclj (11)
- # lein-figwheel (14)
- # leiningen (22)
- # off-topic (53)
- # om (373)
- # omnext (2)
- # onyx (67)
- # parinfer (193)
- # re-frame (23)
- # reagent (89)
- # yada (7)
With boot-cljs
, is there a way to pass environment variables from a boot task to one of the :init-fns
or to ClojureScript in general?
If there isn't, I can probably work around it by generating a cljs config file via a custom task on the fly, just before cljs
. If anyone has a better idea, I'd be happy to hear it
@jannis: you can check out https://github.com/adzerk-oss/env
@micha np! I've spoke to the CIDER dev and submitted a PR to show complete end to end from config to browser repl
Yeah, similar here. My app spawns two services, one serving the backend, the other serving the client. I'd like to be able to pass in the ports both server from via boot, so e.g. the client knows which port use in order to talk to the backend.
@naomarik: did you see the boot wiki? perhaps you could add your config to the cider howto there?
it was way easier getting started with boot and seems faster than lein, and i honestly have an insanely superficial understanding of both just starting on all this yesterday
@micha you guys have most of the instructions ready and done here https://github.com/adzerk-oss/boot-cljs-repl
and tenzing wasn't very helpful giving me 5 old dependencies (that i had no idea were old)
@micha: Right, so you do that outside your tasks and then you have access to BACKEND_URL
from all Clojure and ClojureScript sources?
and you can make them :required
and it will throw an exception with the name of the thing that wasn't configured
so then when i deploy to any kind of application container in the cloud i can set env vars on the environment
the basic concept is to try to store environment-specific configuration in the environment itself, not in a big map in a config file
doing it that way automatically avoids all the issues of sensitive info being in config files , etc
Oh, what if I build the whole project into an uberjar for deployment and run it with java -jar <uberjar>
? Where would I define env vars then? Not in build.boot
I guess because that's not part of the jar.
@micha: Hm. If I do SERVER_URL=<something> boot run-development
, and print (env/env)
in ClojureScript, I can see SERVER_URL
. However, if I do (env/def SERVER_URL :required)
, it's nil
.
(println (get (aenv/env) "SERVER_URL"))
prints the URL, so it's set (note I'm passing a string to get
).
where should I check if my DOM is getting wiped on code reloads and giving me Target container is not a DOM element.
`(defn hook-browser-navigation! [] (doto (History.) (events/listen EventType/NAVIGATE (fn [event] (secretary/dispatch! (.-token event)))) (.setEnabled true))) ` using this code block that came from my luminus project
(defn mount-components []
(reagent/render [#'page] (.getElementById js/document "wrapper")))
(defn app-init! []
(install-devtools!)
(log/debug "starting app")
(mount-root!)
(history/setup-history! (.-body js/document)))
(defn app-reload! []
(log/debug "reloading app")
(mount-root!))
{:require [presentation.frontend.core]
:init-fns [presentation.frontend.core/app-init!]
:compiler-options {:main "presentation.frontend.core"
:asset-path "/assets/javascripts/application.out"}}
(br/reload :ip "0.0.0.0" :ws-host "himitsu" :on-jsload 'presentation.frontend.core/app-reload!)
So you separate things you want to redo each time (like remounting React components) from things you want to just once (likes setting cljs devtools or configuring timbre).
Though I'm curious why hook-browser-navigation!
complained in the first place. You forgot to specify a DOM node to listen
?
That are online? Not really. The only thing I've done that is on-line is http://pinshape.com, but that's in Ruby and it has changed a lot since I've jumpstarted it.
https://gitlab.com/jaen/clj-cljs-presentation/blob/master/src/presentation/frontend/core.cljs#L26
i don't think so, my naive understanding is that it registers an event for NAVIGATE then calls secretary functions
Compare with here - https://closure-library.googlecode.com/git-history/docs/class_goog_events_EventHandler.html
(events/listen
EventType/NAVIGATE
this block listens to probably window navigate eventhttps://closure-library.googlecode.com/git-history/docs/class_goog_History.html right here
Secretary example also specifies something - https://github.com/gf3/secretary#example-with-googhistory
Does anyone remember when Github finally started showing build.boot
files as clojure?