Fork me on GitHub
#figwheel-main
<
2018-08-18
>
euccastro03:08:56

how would you implement logic differences between development and production in a figwheel-main/tools-deps project? for example, I have a website with multiple pages, some of which contain no JS at all. in development I still want to send my main.js to those pages so I get CSS reloading. in production I don't want to load any .js unless necessary

euccastro03:08:13

I can think of a number of ways to do it, but I wonder if there's some idiomatic solution

euccastro03:08:39

one way would be to have :dev and :production tools.deps aliases with "dev" and "production" :extra-paths, and have some myproject.stage namespace defined in both, with different implementations reflecting the logic differences

euccastro03:08:21

another way would be to use https://github.com/weavejester/environ and set an :in-development flag in Java system properties (again, in the :dev alias). then check for this flag whenever I want different behavior in dev vs production

euccastro03:08:55

any simpler ones (or any others you prefer for any reason)?

sooheon06:08:57

[here](https://figwheel.org/docs/your_own_page.html) the docs mention running your own server alongside. How do I keep figwheel from opening localhost:9500, and only compile continuously to target dir so i can run my own server?

onetom07:08:06

That page links to the documentation of the :open-url config option: https://figwheel.org/config-options#open-url that documentation starts as: > Either a boolean value false or a string that indicates the url that the figwheel REPL will open in the browser after the source code has been compiled. A false value will disable this behavior.

sooheon14:08:01

Thanks, this is it :)

bhauman09:08:30

@euccastro you do not want to have two versions of the same namespace behave differently.

bhauman09:08:20

what you want is to use goog-define along with :closure-defines

euccastro15:08:14

@bhauman but that is clojurescript-only, right? I'd rather not have two different systems for clj vs cljs

bhauman15:08:08

Then you will need to forward the environ variable to the :closure-defines in a script

bhauman15:08:41

but :closure-defines is the very best way to do things conditionally in CLJS

bhauman15:08:12

everything else is prone to problems

bhauman15:08:25

the different paths thing can certainly work though, I’m still stuck thinking about working with leiningen and cljsbuild and lein figwheel. Having a conditional path to a namespace didn’t work very well because you had less control over what the plugin does to the classpath.