Fork me on GitHub
#lein-figwheel
<
2018-06-06
>
tungsten15:06:49

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

bhauman15:06:46

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

tungsten15:06:41

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

bhauman15:06:52

in the compiler options map

tungsten15:06:41

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

tungsten15:06:47

:main app-name.core

tungsten15:06:54

in our dev profile

bhauman15:06:52

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

bhauman15:06:12

you likely need to clean out your compiled assets

bhauman15:06:48

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

tungsten15:06:56

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

tungsten16:06:20

where is the index.html file generated?

tungsten16:06:48

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

bhauman16:06:59

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

tungsten16:06:46

that isn't present in this project

tungsten16:06:56

maybe it got deleted?

tungsten16:06:05

does it auto-regenerate one?

bhauman16:06:35

figwheel itself neither serves or auto generates an index

tungsten16:06:58

we are using the "ring-handler" feature

bhauman16:06:05

perhaps you are using something generated by another generator

tungsten16:06:52

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

tungsten16:06:27

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

bhauman16:06:15

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

tungsten16:06:17

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

bhauman16:06:28

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

tungsten16:06:31

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

tungsten16:06:40

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

bhauman16:06:08

ok well that's a big problem

tungsten16:06:09

well "app" project I should say

tungsten16:06:24

Can I exclude that file?

tungsten16:06:35

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

bhauman16:06:36

the library needs to be changed period

tungsten16:06:22

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

bhauman16:06:34

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

tungsten16:06:48

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

bhauman16:06:12

@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

bhauman16:06:03

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

tungsten16:06:18

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

bhauman16:06:56

yes it serves all resources that are in a public subdirectory

tungsten16:06:17

how does figwheel serve "dev-resources"?

tungsten16:06:24

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

bhauman16:06:59

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

tungsten16:06:09

so its a leiningen quirk?

tungsten16:06:11

Thanks so much for your help here

👍 4