Fork me on GitHub
#boot
<
2016-04-30
>
brianosaurus00:04:03

How does one include external javascript (mixpanel, fullstory, google analytics) but only conditionally for prod and/or staging (but not dev) ?

dimiter00:04:14

You mean to compile it into your main.js?

brianosaurus00:04:07

not necessarily. We do want to use the mixpanel functions to send through specific info. However that happens.

jupl01:04:55

I asked something similar earlier. It seems the best way is to create separate entry points and compile based on environment.

brianosaurus01:04:16

and use sift to move stuff into the jar?

dimiter01:04:06

Use merge-env! or set-env! to customize the resource paths.

jupl01:04:19

Possibly. I mean along the lines of creating separate tasks that either run or configure the cljs build task to build the entry points you only need using :ids.

jupl01:04:42

Oh you mean assets.

jupl01:04:05

I thought you meant referencing CLJS wrapped code in CLJS.

brianosaurus01:04:07

yeah, imagine a mixpanel.js snippet that we only want to include when it’s prod

jupl01:04:22

What @dimiter said. 😛

dimiter01:04:35

Ill give you a sample, just a sec.

brianosaurus01:04:43

cool, thanks @jupl and @dimiter simple_smile

jupl01:04:18

sift is also another approach depending on how you want to approach it.

jupl01:04:21

If you got separate folders then tweaking the resource paths works. If you got everything in one folder and you want to filter then sift would be convenient.

dimiter01:04:58

(deftask dev
         "Start the dev env..."
         [s speak bool "Notify when build is done"
          p port PORT int "Port for web server"]
         (merge-env! :resource-paths #{"env/dev/js"})
         (comp
           (watch)
           (reload :on-jsload 'torcaui.core/reinstall-om!)
           (cljs-repl)
           (cljs :ids #{"main" "devcards"})
           (serve :port port :dir "target" :not-found 'reps.server/not-found-handler  :reload true)
           (target)
           (if speak (boot.task.built-in/speak) identity)))

(deftask package
         "Build the package"
         []
         (merge-env! :resource-paths #{"env/prod/js"})
         (comp
           (cljs :compiler-options {
                                    :devcards false
                                    :optimizations :advanced
                                    :externs ["externs/jquery-1.9.js"]})

           (target)))

dimiter01:04:08

In this case, if I am running PROD, it will copy all files from env/prod/js into target/

jupl01:04:02

Actually since it's brought up when using sift with regexs, is the convention for directory separations always / or is there the chance that it's different like on WIndows with \?

dimiter01:04:41

Always use /. From my experience on Windows with Java, that seems to work.

brianosaurus01:04:46

oh wow, thanks @dimiter

jupl01:04:13

@dimiter: Good. One less thing for me to worry about.

nonrecursive14:04:56

hey dudes, I’m trying to write a library that includes some boot tasks, and I’m trying to test the tasks. I have

(deftest bootstrap
  (boot (tasks/bootstrap-db :uri uri)))

nonrecursive14:04:26

and when I try to run the test with boot-test I get Caused by: java.lang.IllegalArgumentException: No implementation of method: :-mk! of protocol: #'boot.tmpregistry/ITmpRegistry found for class: nil

nonrecursive14:04:49

was just wondering if anyone has suggestions for how to get the test running?

nberger15:04:24

@nonrecursive: did you take a look to https://github.com/boot-clj/boot/blob/master/boot/core/test/boot/task/built_in_test.clj? You could take a similar approach. Only thing is that it's only in 2.6.0-SNAPSHOT AFAIK

nonrecursive15:04:05

hadn’t seen that! thanks simple_smile

richiardiandrea18:04:40

Yes @nonrecursive and ask me if anything ok ;)

jupl18:04:41

I'm working on a Boot module right now. Do I need to push it up or is there a way I can install locally to test it in a boot project?

richiardiandrea18:04:42

@jupl do you mean a task or a namesapce? In general you install it locally and you require as any other Clojure namespace

jupl19:04:12

Well basically test it as a dependency before I would push it up someplace like Clojars or something. So reference it from another project. I want to make sure if it works all wired up properly.

richiardiandrea19:04:20

So yeah, I would suggest to have bootlaces in your project and install locallyz, let me fetch an example for you

jupl19:04:02

So how do I install locally with bootlaces?

adamkowalski19:04:03

Hey, when I try to enter the cider debugger it gives me an error, and I cannot fix it until I run (boot.core/load-data-readers!) in the repl

adamkowalski19:04:33

is there a better way to fix this problem with boot? or is that just something people do when they first start the repl

adamkowalski19:04:12

actually I guess I can put (#'clojure.core/load-data-readers) (set! data-readers (.getRawRoot #'data-readers)) after my set-env! in my build.boot and that solves the problem

jupl19:04:39

Ah looks like build-jar does that.

richiardiandrea20:04:07

Yeah, just set up bootlaces dep and then build-jar

alandipert21:04:14

@adamkowalski: you can also put that in your ~/.boot/profile.boot

adamkowalski21:04:10

awesome, thanks for the tip!

danielsz21:04:25

@adamkowalski: Boot-system does that for you as well. simple_smile

danielsz21:04:09

@alandipert: I've had difficulties with remove-ns inside boot tasks. Does that ring a bell?

adamkowalski21:04:39

@danielsz: how do you like component vs mount?

danielsz21:04:39

@adamkowalski: I like the idea of both, but I've had only experience with component. We're working on integrating mount in system, too!

adamkowalski21:04:56

very cool, I will definitely check it out because I like the idea of community managed components. seems like a really good way to enforce best practices and quickly set your project up with the various dependencies it might rely on

danielsz21:04:17

@adamkowalski: Exactly. That's the idea.

danielsz21:04:40

@alandipert: Basically, when I do a require ns-sym :reload after remove-ns ns-sym in a boot task I don't see the new code.

danielsz21:04:29

@alandipert: I'm currently investigating, but I thought to ask if that sounds like something you've encountered.

richiardiandrea22:04:40

I also like the fileset-driven reloading workflow, I saw that there was a problem with the system task but I have to say that it is awesomely thought out ;)

richiardiandrea22:04:22

Bootos to @danielsz boot-clj

alandipert23:04:39

@danielsz: hm unfortunately i don't recall running into that ever