Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify and access environment variables #685

Open
dchacke opened this issue Apr 27, 2018 · 1 comment
Open

How to specify and access environment variables #685

dchacke opened this issue Apr 27, 2018 · 1 comment

Comments

@dchacke
Copy link

dchacke commented Apr 27, 2018

I understand Figwheel allows me to specify different builds. (Perhaps another way to think of them is as environments?)

Based on the build/environment, I may require a different behavior in my code. For example, when in dev, I connect to a certain API endpoint, and in prod it's a different endpoint. Ideally, I would like some way (presumably this belongs in project.clj) of specifying environment specific variables, and then access them in my cljs code.

Is there a mechanism to do this?

I'm picturing something like this:

:cljsbuild {
    :builds [{:id "dev"
              :source-paths ["src"]
              :figwheel true
              :env-variables {foo "bar"
                              bar "foo"} ; <--------
              :compiler {:main hello-seymore.core 
                         :asset-path "cljs/out"
                         :output-to  "resources/public/cljs/main.js"
                         :output-dir "resources/public/cljs/out"} 
             }
             {:id "prod"
              :env-variables {foo "different value for foo"
                              bar "different value for bar"}}] ; <--------
              ; etc
   }

And then in my cljs code I would like to access them somehow. If it matters, I am running a Reagent project.

@bhauman
Copy link
Owner

bhauman commented Apr 27, 2018

Your going to want to direct this question to the Clojurians slack.

Sign up:
http://clojurians.net
Sign in:
http://clojurians.slack.com

Channels of interest to this topic:
#clojurescript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants