how do you import css from npm?
There is a discussion in reagent channel https://clojurians.slack.com/archives/C0620C0C8/p1606990103333000
I am not sure if it helps me though. I am writing a react component, not html.
Someone else writes it, but for them the css should be bundled with my component
No cljs build tool I know of handles asset imports. So you’ll need to include the CSS manually
If you’re writing a lib, your consumers will need to do the same
In the past I’ve used CSS-in-JS libs for this reason; it’s more portable
I've not tried the new webpack stuff to see if that works.
this is in-company
so not a library, obviously, as I said, but also not even a package. I don't have to publish it and only have to work inside our own django application.
and I am fully aware of webpacks all bloated features are not part of all other bundler's features and I am glad for this because I don't like webpack
but I can't really expect people who will use my component internally to the react app, to then go to the django template file and inject the required css lines
similarly, it is not really a good idea to include the css for components that are not present, so if they remove the component, how can I make sure they remove the css from the html templates?
I am really curious what people do to get over this
Webpack :)
Or css-in-js
I see that you see why I ask 🙂
it shows that clojure is still mostly about backend, because I expect if your backend is clojure, this just goes to a bunch of other backend scripts. E.g. I could use some django plugin
And how does django find the css? My recollection is fuzzy here, but I'm sure there's a manifest you can generate.
Or python
I am not that good with python/django, so I don't know
There is a thing called collectstatic that needs to run before deploy. But even that is not the defacto standard or anything, and people do all kinds of weird things, like in php. At least that's my impression
Django is pretty standardized, it's not as wild west as php. Although that's rounding up with things like composer.
https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#django-admin-collectstatic
https://docs.djangoproject.com/en/3.1/ref/settings/#std:setting-STATICFILES_DIRS can have your library added to it, and you're good to go.
yeah, but that's not very dynamic, is it?
it's even called static
guess i am overoptimizing or something, but this whole setup feels ad hoc
I don't understand what dynamic would be here.
Sorry, I realized in the meantime that I am coming at this from the wrong angle. Let me try differently: I would like to not have to consciously think about including or not including css dependencies of my dependencies.
I should've been more specific, but I am only figuring this out now, sorry.
That's OK. Most of what I ever ask is implicit. I like Clojure's melting pot because we're all so different and have very little shared background. Opens us up to new ideas.
So you're like building a thing, and you depend on another thing, which itself has CSS? And you'd like to automate the process of bundling all those up automagically?
That sounds exactly like webpack to me :) (or any other bundler)
yeah