This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-17
Channels
- # aleph (3)
- # announcements (12)
- # beginners (80)
- # boot (3)
- # braveandtrue (16)
- # calva (3)
- # cider (82)
- # clojure (100)
- # clojure-art (3)
- # clojure-dev (79)
- # clojure-estonia (1)
- # clojure-europe (4)
- # clojure-finland (15)
- # clojure-indonesia (1)
- # clojure-italy (20)
- # clojure-nl (4)
- # clojure-spec (24)
- # clojure-sweden (2)
- # clojure-switzerland (1)
- # clojure-uk (99)
- # clojurescript (145)
- # cursive (8)
- # data-science (7)
- # datomic (26)
- # emacs (4)
- # figwheel-main (20)
- # fulcro (8)
- # graphql (3)
- # hoplon (2)
- # jobs (1)
- # kaocha (5)
- # leiningen (2)
- # liberator (19)
- # off-topic (16)
- # pathom (9)
- # perun (1)
- # portkey (2)
- # re-frame (17)
- # reitit (1)
- # shadow-cljs (26)
- # spacemacs (7)
- # vim (49)
is there a way to turn off devtools for just one module in a dev build that has devtools enabled? my webworker is failing because it's loading the devtools stuff and turning it off in the module section doesn't seem to do anything:
:devtools {:http-root "admin/public"
:http-port 1337
:after-load threshold.admin.core/reload
:preloads [fulcro.inspect.preload threshold.admin.development-preload]}
:modules {:main {:init-fn threshold.admin.core/main
:entries [threshold.admin.core]}
:worker {:devtools {:enabled false}
:entries [threshold.admin.worker.core]
:depends-on #{:main}
:web-worker true}}
What are some good ways to bring in variables from system environment variables? I'm currently using a macro with direnv, however I think I'm having some caching issues
system environment variables is usually a code smell. why are you using env vars in a browser app?
I have multiple environments develop, staging & production each with it's own backend infrastructure. I compile on CircleCI where I use the git branch to decide what environment variables to use. My application is compiled with those environment variables.
I'm injecting them kind of like how create-react-app does it for ReactJS https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables
we do similar, but we have other ways of discerning which env we’re in. e.g. by host name, or by a global var on the page inserted by the back end
that way our builds are portable. it seems weird to have to compile your app for each environment
I'm hosting static html files so I can't insert them dynamically with a web server.
@caleb.macdonaldblack I generally recommend avoiding environment variables for browser builds and instead passing data to the build from HTML
but you can use #shadow/env "FOO"
in the build config to access environment variables
or use :cache-blockers
to prohibit caching of files that use side-effecting macros https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache
What do you mean by passing data from html?
@caleb.macdonaldblack I generally recommend using an init
function. (defn ^:export init [some-config] ...)
<script>your.ns.init({"url":"http://..."});</script>
alternatively <script>var MY_CONFIG = {...};</script>
and then accessing js/MY_CONFIG
that pattern makes most sense if you have a dynamic webserver and not just static html files though
Yea Im using static html files but I can see how incredibly useful that method would be for dynamic stuff. Im not sure what you meant by index-ci.html though. Are you suggesting multiple index-*.html files with different configs for my environments and the copying that file to index.html when I deploy?
if you are not using a dynamic web server yes. you can either copy or generate different html files depending on the environment
Okay. From your suggestions I think I prefer the #shadow/env method for static hosting plus it works well with my current setup. However I really like the other method for dynamic web servers. Thanks a lot for the help.
Hi!
I'm getting a ReferenceError: garden is not defined
, but I can't figure out why. It happens while using cljs code as a regular module on webpack. The CLJS code targets :npm-module
and is generated with the compile
task.
The component in question uses https://github.com/matthieu-beteille/cljs-css-modules, and adding garden.core
on the ns
that uses it "solves" the problem.
The compiled webpack bundle contains modules for cljs-css-modules
, garden
and my component, as expected. cljs-css-modules
contains a __webpack_require__
pointing to garden
's module.
Without garden.core
explicitly required, my component's module contains a __webpack_require__
to cljs-css-modules
but it fails.
With garden.core
require outside the ns
(via a macro that outputs a require
), the module gains a goog.require('garden.core')
but it still fails.
With garden.core
explicitly imported on the component, the webpack module gains a __webpack_require__
to the garden
module, a garden=$CLJS.garden
and a goog.require('garden.core')
. Everything works.
What is confusing me is that cljs-css-modules
imports garden.core
, and my code both requires and webpack_require
s cljs-css-modules
. Is it expected to have to require garden
again?
It works beautifully! Thanks again!