This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-16
Channels
- # 100-days-of-code (16)
- # beginners (67)
- # boot (5)
- # cljs-dev (52)
- # cljsjs (2)
- # clojure (94)
- # clojure-spec (34)
- # clojure-uk (10)
- # clojurescript (91)
- # clojutre (1)
- # core-async (20)
- # cursive (5)
- # datomic (1)
- # figwheel-main (70)
- # fulcro (101)
- # hyperfiddle (3)
- # jobs (1)
- # klipse (16)
- # mount (1)
- # nrepl (3)
- # off-topic (24)
- # portkey (39)
- # re-frame (4)
- # reitit (1)
- # shadow-cljs (3)
- # spacemacs (9)
- # tools-deps (5)
@kwladyka I haven’t tried it with figwheel-main but you can usually add a non local directory to :watch-dirs
Example :watch-dirs ["src" "../form-validator-cljs/src"]
I have recently started using clojure and cljs and tried out figwheel-main after finding out about it. It feels great! Now I want to deploy my app to a server and I'm failing to create an uberjar containing the "target" dir contents.
It might be because I'm new to the whole thing and not figwheel-main specific, but I feel like I may be overlooking something in figwheel-main that could help me do this.
So far I've tried adding in cljsbuild and running that before creating an uberjar (it still doesn't work), but is that even the right path?
I'm sorry, I got it to work! I forgot to add a resource route. When using lein fig:build
, everything works magically for a newbie like me and it seems I have to learn the rest the hard way 🙂
@johb.maier yeah there needs to be a guide on figwheel that shows specifically how to do this and as you discovered its easiest with lein
as you don’t have to have a jar, you could just be deploying compiled assets somewhere
@bhauman I ended up adding cljsbuild to my project.clj
which then compiles the js output to resources/public/cljs-out
. But then I have to gitignore this subdir and I'd love to know how to be able to just package the compiled js that figwheel creates in the target
dir into my jar so that it can then be used with that. Is there a way to do this?
@johb.maier you need to add target
to your :resource-paths
so that its contents get added to the uberjar
you can also make a prod.cljs.edn
{:main example.core :optimizations :advanced :output-to "resources/public/cljs-out/dev-main.js"}
@bhauman Also thanks for creating this amazing tool! I come from a desktop application, windows and OO only background with an aversion to web development and with figwheel it's just, well, fun!
I’m really considering switching to a different server in the hopes on not conflicting with jetty
Ok, I got a quick sample program up and running with figwheel.main/cider and clj tools. Is there an equivalent to the lein “on-jsload” or do I put it into my dev.cljs.edn? and add a example.core/mount-root
@bhauman so it works when I call it manually (refer.app/mount) but it doesn’t seem to be doing the hot-reloading. How can I check what it thinks the hooks are?
I was going by this example
;; this is what you call for the first mount
(defn ^:export mount []
(r/render [my-main-component]
(js/document.getElementById "app")))
;; and this is what figwheel calls after each save
(defn ^:after-load re-render []
(mount))
so I added.
(ns ^:figwheel-hooks refer.app
(:require
[reagent.core :as reagent]
[re-frame.core :as re-frame]
[refer.events :as events]
[refer.views :as views]
[refer.config :as config]))
;; Setup config paramaters.
(defn dev-setup []
(when config/debug?
(enable-console-print!)
(println "dev mode")))
;; Grab the base component and render it.
(defn mount-root []
(.log js/console "Starting App")
(re-frame/clear-subscription-cache!)
(reagent/render [views/main-panel]
(.getElementById js/document "app")))
;; Starting / Entry point for the app.
(defn ^:export init []
(.log js/console "Starting init")
(re-frame/dispatch-sync [::events/initialize-db])
(dev-setup)
(mount-root))
(defn ^:after-load re-render[]
reagent/render [views/main-panel] (.getElementByIdjs/document "app"))
fixed it same thing. is there a way to see what figwheel-main thinks the ^:export and ^:after-load is?
but the console should complain if the call on your html page isn’t able to call the init
fn
I had this happen once, which was surprising to me because my call to init
was in a window.onload
callback. Does anyone have a sense of what can cause this to happen / what can be done to prevent it?
ah that makes sense. Thanks for the help. Been spending a couple of days moving from Lein to clj and ti’s bene making me understand all the internal plumbing more than I ever have.
Dropping it into a defonce made it all work. The tutorial waas great in that it really helped see where the plumbing in clojurescript was and also how to get the repl working.
The only think that was missing is a simplifed deps.edn and build to use it with the clojure command line tools.
I had this happen once, which was surprising to me because my call to init
was in a window.onload
callback. Does anyone have a sense of what can cause this to happen / what can be done to prevent it?