figwheel

general discussion about figwheel, specific discussions in #figwheel-main and #lein-figwheel
bhauman 2018-11-24T15:18:46.026600Z

@jsa-aerial its probably because of the path that you are using for your main.js script

bhauman 2018-11-24T15:18:57.026900Z

make sure its absolute and not relative

bhauman 2018-11-24T15:20:00.028100Z

i.e <script src="/path/to/main.js"> not <script src="path/to/main.js">"

jsa-aerial 2018-11-24T18:39:41.033600Z

@bhauman I tried that but the results are the same. Poking around some more, I see from console log that the server (in Figwheel) expects everything (entire directory structure) to be under a Fig/public directory instead of just the usual public directory. So, nothing in the iindex.html file is found or loaded (including the "main.js" script. I even tried giving the absolute path starting with /public but server still tries loading from Fig/public(?!?).

jsa-aerial 2018-11-24T18:45:18.036600Z

OK, I even tried putting absolute and relative resources in front. With /resources/public/path/to/main.js the path is actually that, but the file is not found (maybe because it is really looking for /resources/resources... ??). If it is relative then it ends up being Fig/resources/.... It doesn't look like it is possible to do this with the way Figwheel currently resolves paths.

bhauman 2018-11-24T19:22:30.037400Z

@jsa-aerial yes something in your setup is off

bhauman 2018-11-24T19:23:58.038700Z

figwheel shouldn’t expect things to be under Fig/public

bhauman 2018-11-24T19:24:32.039400Z

shoudn’t

jsa-aerial 2018-11-24T19:25:16.040500Z

OK - I don't have any other 'path' stuff configured - maybe there is an option I'm missing?

bhauman 2018-11-24T19:26:43.042Z

can you show me your code in a gist?

bhauman 2018-11-24T19:26:52.042300Z

mostly config stuff

bhauman 2018-11-24T19:27:23.043400Z

do you have the tree program installed so that I can get a quick look at your directory structure?

jsa-aerial 2018-11-24T19:27:27.043700Z

One thing I do know. This project actually is all about setting up a client and server and when I start the projects server (on another port) it can serve the Fig/index.html and correctly serve all the other resources.

jsa-aerial 2018-11-24T19:28:11.044300Z

So, it is definitely something about how figwheel is configured or setup.

jsa-aerial 2018-11-24T19:29:00.045200Z

Frankly, one 'solution' is to just browse to the projects server address and things simply work. But that's a bit annoying

bhauman 2018-11-24T19:29:35.045700Z

why do you need to browse there, that’s what :open-url is for??

jsa-aerial 2018-11-24T19:33:17.047100Z

Exactly - except figwheel does not get the resources correct. The project server does

bhauman 2018-11-24T19:34:10.048200Z

@jsa-aerial does figwheel work when you are using the project server?

jsa-aerial 2018-11-24T19:35:09.049200Z

So, to be explicit this <http://localhost:3449/Fig/index.html> (which opens automatically) gets the resources wrong, but this <http://localhost:3003/> gets the resources correct.

jsa-aerial 2018-11-24T19:35:50.050500Z

That's because it correctly serves up the 'main.js' script

bhauman 2018-11-24T19:36:02.050800Z

and you can now have :open-url "<http://localhost:3003>"

jsa-aerial 2018-11-24T19:36:33.051200Z

OK - that sounds like a plausible solution - didn't know that

jsa-aerial 2018-11-24T19:38:05.052300Z

Maybe there is something else wrong - I have :open-urls as the key (note ending 's'). Is that wrong? I got this from a template

bhauman 2018-11-24T19:38:51.052700Z

Are you using lein-figwheel ?

bhauman 2018-11-24T19:39:02.053Z

sorry I thought you were using figwheel-main.

bhauman 2018-11-24T19:39:17.053400Z

for lein-figwheel :open-urls is correct

jsa-aerial 2018-11-24T19:41:10.055200Z

I'm pretty sure I'm using figwheel-main. Well, I start by getting a repl (just lein repl) and then issue (use 'figwheel-sidecar.repl-api) and then (start-figwheel!)

bhauman 2018-11-24T19:41:25.055500Z

no that is not figwheel-main

bhauman 2018-11-24T19:41:53.056200Z

you should be using :open-urls

jsa-aerial 2018-11-24T19:43:09.056800Z

OK. I also have this for dev profile:

jsa-aerial 2018-11-24T19:43:20.056900Z

jsa-aerial 2018-11-24T19:44:46.057500Z

OK, yes, I am using lein-figwheel: [lein-figwheel "0.5.16"]

jsa-aerial 2018-11-24T19:45:16.058200Z

Which only goes to show how little I understand about how this is all plumbed...

bhauman 2018-11-24T19:45:50.059Z

have you tried putting the locahost:3003 url in :open-urls?

jsa-aerial 2018-11-24T19:46:03.059300Z

Pretty much just following a 'cookbook recipe'

jsa-aerial 2018-11-24T19:46:14.059500Z

Let me try that

jsa-aerial 2018-11-24T19:50:06.059700Z

Yes, just plain works

jsa-aerial 2018-11-24T19:53:34.061400Z

And figwheel is still opening up port localhost:3449 - and if you browse there still serves up wrong paths. Shrug.

jsa-aerial 2018-11-24T19:57:08.063900Z

Since I always have the project server start (and in testing always use 3003) I can just use :open-urls with that address and things will just work. Still, seems odd that the server at 3449 doesn't get this right. One thing the project server also does is set the resources route to "/": (route/resources "/"). Maybe figwheel doesn't do that?