Fork me on GitHub
#shadow-cljs
<
2021-04-26
>
fsd15:04:42

Hello There, I have a quick question, I am new in clojure How do I use png file in cljs? I have a shadow cljs application for example "./icons/marker.png I’ve tried using this but it’s not loading

Azzurite15:04:49

This has nothing to do with shadow-cljs, try #beginners or #clojurescript But generally, you need to start a webserver and serve that file on the webserver you started shadow-cljs has https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http, but you don't want to use that for your final app...

thheller15:04:25

how are you embedding it? this is not a CLJS question really, more HTML specific. if you use ./ in the path it'll be relative to the page you are on. you need to make sure the path is correct.

sova-soars-the-sora18:04:58

Hi, how can I name the file something other than main.js?

Aron18:04:25

this caught me too, the key in the map decides

Michaël Salihi20:04:44

Hi there. Is it possible to invalidate the node_modules cache without restarting npx shadow-cljs watch app ? Any option?

thheller20:04:46

invalidate why? I mean what do you expect that to achieve?

Michaël Salihi20:04:10

I put some console.log on npm package for debugging.

thheller20:04:40

you can touch node_modules/that-package/package.json to trigger a recompile

👍 3
Michaël Salihi20:04:13

I don't have any output, so I supposed that's because Shadow cache.

Michaël Salihi20:04:23

Oh perfect, thx!

thheller20:04:04

yeah I removed individual file watching for node_modules files because some projects used like 5000 files from there and that was causing some performance issues

thheller20:04:20

but it still watches package.json files in cause you npm install stuff or so

thheller20:04:37

touching the package.json will invalidate the entire package

Michaël Salihi20:04:09

Yeah I understand, very good reason performance wise. Thanks Thomas.

pez20:04:21

Is there a reason I should defonce my app-db in a re-frame project from a hot-reload perspective?

thheller20:04:26

yes, without it the hot-reload will just replace it with a new atom when you modify the file

thheller20:04:05

defonce is needed if you want to keep your state

pez20:04:44

The state seems to be kept in the re-frame.db/app-db ratom. I notice no difference when I use def on my app-db. hot reload seems to work the same.

thheller20:04:19

then I don't understand your question. when using re-frame you don't have your own app-db?

pez20:04:10

I am asking because I am going to present ClojureScript app development on a meetup Wednesday. And I had sort of planned to mention defonce as a protector of the app-db, but when I tested it I noticed that that part of the demo doesn’t seem to hold. Looking in re-frame.db then, it’s app-db is also just (def app-db (ratom {})) . I just want to understand a bit better how it really works. Even if I realize I should stay away from the subject during the demo. 😃

thheller20:04:27

well you don't modify the re-frame.db namespace so it is never reloaded and never has this issue

pez20:04:41

Ah. Thanks!

thheller20:04:45

if you have this is your main namespaces that is constantly getting reloaded you will lose your state every time without defonce 😉

pez21:04:34

Yeah, I can totally get it to happen with a local atom and such. Which added to my confusion.