lein-figwheel

2018-06-06T15:40:49.000259Z

How does figwheel determine which script to load in the webpage it serves? I added a clojurescript library to my leiningen project and now figwheel is trying to serve "/js/compiled/library.js" instead of "/js/compiled/app.js" like it used too... the end result is my app doesn't run

bhauman 2018-06-06T15:53:46.000064Z

@bfast the :main option determines the main namespace to be loaded in the :output-to file

2018-06-06T15:54:41.000084Z

@bhauman in the :figwheel map, or the cljsbuild compiler map?

bhauman 2018-06-06T15:54:52.000801Z

in the compiler options map

2018-06-06T15:55:41.000199Z

very strange.... we have that set to our "app" not the library

2018-06-06T15:55:47.000867Z

:main app-name.core

2018-06-06T15:55:54.000822Z

in our dev profile

bhauman 2018-06-06T15:56:52.000892Z

and if you look at the contents of your output to file you will see it requiring that,

bhauman 2018-06-06T15:57:12.000744Z

you likely need to clean out your compiled assets

bhauman 2018-06-06T15:57:48.000311Z

its probably just not finding the library where you are requiring it

2018-06-06T15:59:56.000391Z

the strange thing is the "uberjar" production build seems to work

2018-06-06T16:01:20.000394Z

where is the index.html file generated?

2018-06-06T16:01:48.000418Z

it seems to me the problem is that it is attempting to load something other than the output to file

bhauman 2018-06-06T16:02:59.000842Z

the index.html is initially generated by the lein figwheel template in resources/public

bhauman 2018-06-06T16:03:39.000450Z

@bfast ^

2018-06-06T16:03:46.000920Z

that isn't present in this project

2018-06-06T16:03:56.000377Z

maybe it got deleted?

2018-06-06T16:04:05.000516Z

does it auto-regenerate one?

bhauman 2018-06-06T16:04:09.000061Z

nope

bhauman 2018-06-06T16:04:35.000052Z

figwheel itself neither serves or auto generates an index

2018-06-06T16:04:58.000060Z

we are using the "ring-handler" feature

bhauman 2018-06-06T16:05:05.000456Z

perhaps you are using something generated by another generator

2018-06-06T16:05:52.000077Z

which is returning html as a string to the "/" endpoint

2018-06-06T16:06:27.000741Z

which is hard coded to load js/compiled/app.js?version=%s

bhauman 2018-06-06T16:08:15.000647Z

did you ensure that you cleaned the compiled assets and then recompiled?

2018-06-06T16:12:17.000716Z

I have done git clean -fxd, lein clean, then "lein with-profiles +dev figwheel dev"

bhauman 2018-06-06T16:14:28.000031Z

If I were you I would use chrome devtools to look at the loaded html and the network loads to determine what specifically is going on

2018-06-06T16:16:31.000120Z

Ok the "library" project contains a resources/public/index.html

2018-06-06T16:16:40.000739Z

it seems that is being served by figwheel in the new project

bhauman 2018-06-06T16:17:08.000515Z

ok well that's a big problem

2018-06-06T16:17:09.000512Z

well "app" project I should say

2018-06-06T16:17:24.000300Z

Can I exclude that file?

2018-06-06T16:17:35.000330Z

The library is a UI library that is setup to work with figwheel + devcards

bhauman 2018-06-06T16:17:36.000467Z

the library needs to be changed period

2018-06-06T16:19:22.000595Z

can devcards generate its own "index.html" ... or how do i get hot reloading to work in that project

bhauman 2018-06-06T16:21:34.000608Z

no it doesn't, but you don't have to have index.html , it can be library-cards.html or cards/index.html whatever you want it to be

2018-06-06T16:22:48.000700Z

Ah ok ... yeah we are using cards.html... but somehow an index.html file is there too

bhauman 2018-06-06T16:25:12.000160Z

@bfast in the libary project I would put your cards.html index.html in dev-resources/public and that will be excluded from consumers of the library and then in your current project put a copy of cards.html in your dev-resources/public

bhauman 2018-06-06T16:26:03.000564Z

this gives you much more control and you don't end up with the weird shadowing

2018-06-06T16:26:18.000827Z

Is the issue that figwheel serves the resources directory by default?

bhauman 2018-06-06T16:26:56.000389Z

yes it serves all resources that are in a public subdirectory

2018-06-06T16:27:17.000230Z

how does figwheel serve "dev-resources"?

2018-06-06T16:27:24.000402Z

do I have to change the resource path in a dev profile?

bhauman 2018-06-06T16:27:59.000129Z

nope dev-resrouces are only available in dev profile which is on during development for the current project

2018-06-06T16:28:09.000360Z

so its a leiningen quirk?

bhauman 2018-06-06T16:38:59.000852Z

yes

2018-06-06T16:44:11.000505Z

Thanks so much for your help here

👍 1