figwheel-main

figwheel-main http://figwheel.org
dominicm 2020-05-18T13:06:48.288100Z

@bhauman it would be handy if a post build hook could be a fn. Just about to read the source to figure out if that's basically already valid and I need to turn off config validation.

dominicm 2020-05-18T13:11:02.288400Z

My use-case is that I'm using a locally scoped fn inside of an integrant component so I have access to a promise I created, which I use to make sure I only start one webpack watcher.

dominicm 2020-05-18T13:17:38.288500Z

I have a workaround for now, so no rush

dominicm 2020-05-18T13:47:09.288600Z

Hacky workaround is to use with-local-vars to bind it it into a clojure.lang.Var

πŸ‘ 1
2020-05-18T22:16:23.297300Z

I'm trying to understand figwheel-main. I've got to a stage where I have a simple layout

.
β”œβ”€β”€ deps.edn
β”œβ”€β”€ deps.edn~
β”œβ”€β”€ foo-dash.cljs.edn
β”œβ”€β”€ resources
β”‚Β Β  └── public
β”‚Β Β      β”œβ”€β”€ css
β”‚Β Β      β”‚Β Β  └── style.css
β”‚Β Β      └── index.html
β”œβ”€β”€ src
β”‚Β Β  └── foo_dash
β”‚Β Β      └── core.cljs
my foo-dash.cljs.edn looks like this:
^{:css-dirs ["resources/public/css"]}                                                                   
{:main foo_dash.core}    
My deps.edn
{:deps {com.bhauman/figwheel-main {:mvn/version "0.2.5"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
        reagent {:mvn/version "1.0.0-alpha2"}}
 :paths ["src" "target" "resources"]}
I run:
$ clojure -m figwheel.main
I get the main figwheel webpage and a repl. Nice, that works. But when I do:
$ clojure -m figwheel.main --build foo-dash --repl
I see my index.html, but no repl... What am I doing wrong here that I never get a REPL?
2020-05-18 23:13:37.941:INFO::main: Logging initialized @3499ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Compiling build foo-dash to "target/public/cljs-out/foo-dash-main.js"
[Figwheel] Successfully compiled build foo-dash to "target/public/cljs-out/foo-dash-main.js" in 0.537 seconds.
[Figwheel] Watching paths: ("src") to compile build - foo-dash
[Figwheel] Starting Server at <http://localhost:9500>
[Figwheel] Starting REPL
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
          (figwheel.main/stop-builds id ...)  ;; stops Figwheel autobuilder for ids
          (figwheel.main/start-builds id ...) ;; starts autobuilder focused on ids
          (figwheel.main/reset)               ;; stops, cleans, reloads config, and starts autobuilder
          (figwheel.main/build-once id ...)   ;; builds source one time
          (figwheel.main/clean id ...)        ;; deletes compiled cljs target files
          (figwheel.main/status)              ;; displays current state of system
Figwheel REPL Controls:
          (figwheel.repl/conns)               ;; displays the current connections
          (figwheel.repl/focus session-name)  ;; choose which session name to focus on
In the cljs.user ns, controls can be called without ns ie. (conns) instead of (figwheel.repl/conns)
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
[Rebel readline] Type :repl/help for online help info
Opening URL <http://localhost:9500>
Then it just sits there, no repl...

bhauman 2020-05-18T22:17:17.297700Z

@qmstuart does a browser pop open?

2020-05-18T22:17:27.298Z

it does, and it disp;lays my Hello, World! with red text from my css

bhauman 2020-05-18T22:18:13.298400Z

and if you reload the browser no change?

2020-05-18T22:18:37.298800Z

nope

2020-05-18T22:18:58.299200Z

I think I'm obviously misunderstanding how the .edn files are used

bhauman 2020-05-18T22:19:11.299700Z

I think you are doing ok actually

bhauman 2020-05-18T22:19:24.300100Z

look in the web inspector console of the browsers devtools

2020-05-18T22:21:32.300900Z

Loading failed for the &lt;script&gt; with source "<http://localhost:9500/cljs-out/cruel-main.js>".
Why it would be looking for a file from the tutorial I went through?

2020-05-18T22:21:48.301200Z

ah, i bet i've copied the index.htnml

2020-05-18T22:21:50.301500Z

and not chnaged it

bhauman 2020-05-18T22:21:56.301800Z

yep

bhauman 2020-05-18T22:22:35.302600Z

yeah if you get rid of the index.html entirely it should work

2020-05-18T22:22:36.302700Z

how should i be naming things? I've noticed I put _ and - in my folder names, which is confusing me.

2020-05-18T22:22:46.302900Z

should i avoid - and _ ?

bhauman 2020-05-18T22:23:08.303300Z

that’s a clojure thing

2020-05-18T22:23:11.303600Z

or just treat it how I do in Clojure when using dashes and underscores with namespaces

2020-05-18T22:23:15.303800Z

oh, so its just the same?

bhauman 2020-05-18T22:23:20.304Z

yep

2020-05-18T22:23:23.304300Z

cool

bhauman 2020-05-18T22:24:10.304800Z

did you see what I said about getting rid of the index.html entirely?

bhauman 2020-05-18T22:24:20.305100Z

figwheel will make one for you

bhauman 2020-05-18T22:24:53.305700Z

and it provides a div on the page with an β€œapp” id that you can write to

bhauman 2020-05-18T22:25:11.306Z

thats to help you bootstrap

bhauman 2020-05-18T22:25:38.306600Z

once things get rolling you can create your own html page with a reference to your main.js

bhauman 2020-05-18T22:26:02.307100Z

but if you use the figwheel index page first its easy to copy it and modify it

2020-05-18T22:26:11.307300Z

great, thanks!

2020-05-18T22:26:24.307800Z

i'm pretty new to front end stuff

bhauman 2020-05-18T22:27:08.308Z

πŸ‘