Hi, I have (in a UIx project) a assets/logo.webp file that I want to :require as ["logo.webp" :as logo]. I tried configuring shadow-cljs.edn as follows:
:js-options {:js-package-dirs ["node_modules" "assets"]}
This ^ doesn't work. Can anyone help me know if this is the right direction, or point at what am I doing wrong?whats the point anyway?I've often wanted to do this to inline SVG icons, when using SVG icons with , currentColor won't be picked up from document context for the SVG, which is a common pattern to set an icon's color.
In Vite and other build tools there is stuff like svgr that converts SVG files to react components at build time
(just sharing for context)
oh it is absolutely useful to have tools for assets. no doubt about that. doing it via require is the part I don't get 😛
there is no support for requiring "assets" that aren't actual CLJS/JS sources
so no images, video or css
whats the point anyway? just move it to public/assets/logo.webp and use /assets/logo.webp in your HTML (assuming public is your http root, might be resources/public)
OK, I am using ChakraUI and need to pass the logo as a React component property.
@thheller Thanks for the pointer - it worked by directly passing {:src "/assets/logo.webp"} as property after moving the logo file to public/assets/logo.webp.
I have a build that consists of several modules and some shared code. What's the best way to have separate dev and production entry points? Details in thread.
{:target :browser
:modules {:shared {}
:module1 {:entries [my.ns.mod1]
:depends-on #{:shared}}
:module2 {:entries [my.ns.mod2]
:depends-on #{:shared}}
,,,}
:dev {:output-dir "dev-resources/public/js"}
:release {:output-dir "target/public/js"}
:compiler-options {:externs ["datascript/externs.js"]
:source-map true}}
I'd like to have dev/myns/mod1.cljs as the entry point for :module1 during development, and prod/myns/mod1.cljs during production - or something along those lines. Do I have to duplicate all the modules to do this, or are there some other shenanigans I can employ?It doesn't have to be classpath shenanigans, the important thing I want to achieve is to load one namespace with devtooling in development, and a leaner one in prod.
are these different source paths? dev and prod? they seem to have the same name? as in myns.mod1? or actual different namespaces?
In the suggestion above I was thinking different source paths. But I guess that's not strictly necessary.
and why do you want to switch them? wouldn't a closure define do to turn on extra "dev" behavior when needed?
or :preloads to inject extra dev only code?
Preloads sounds interesting!
switching :modules between modes is always going to be a bit verbose
Exactly. I'll look into preloads 👍
for example with shadow.grove I inject the devtools via preload https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L104
yeah, this is exactly what I want 👍