Fork me on GitHub
#helix
<
2020-12-11
>
Aron12:12:36

how do you import css from npm?

Aron14:12:41

I am not sure if it helps me though. I am writing a react component, not html.

Aron14:12:03

Someone else writes it, but for them the css should be bundled with my component

lilactown16:12:08

No cljs build tool I know of handles asset imports. So you’ll need to include the CSS manually

lilactown16:12:29

If you’re writing a lib, your consumers will need to do the same

lilactown16:12:46

In the past I’ve used CSS-in-JS libs for this reason; it’s more portable

dominicm18:12:46

I've not tried the new webpack stuff to see if that works.

Aron18:12:21

this is in-company

Aron18:12:51

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.

Aron18:12:27

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

Aron18:12:09

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

Aron18:12:27

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?

Aron18:12:42

I am really curious what people do to get over this

dominicm19:12:52

Or css-in-js

Aron19:12:01

I see that you see why I ask 🙂

Aron19:12:55

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

dominicm20:12:13

And how does django find the css? My recollection is fuzzy here, but I'm sure there's a manifest you can generate.

Aron21:12:18

I am not that good with python/django, so I don't know

Aron21:12:12

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

dominicm21:12:08

Django is pretty standardized, it's not as wild west as php. Although that's rounding up with things like composer.

Aron21:12:47

yeah, but that's not very dynamic, is it?

Aron21:12:53

it's even called static

Aron21:12:29

guess i am overoptimizing or something, but this whole setup feels ad hoc

dominicm22:12:46

I don't understand what dynamic would be here.

Aron22:12:17

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.

Aron22:12:22

I should've been more specific, but I am only figuring this out now, sorry.

dominicm22:12:50

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.

dominicm22:12:40

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?

dominicm22:12:26

That sounds exactly like webpack to me :) (or any other bundler)