Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS-in-rs #27

Open
qm3ster opened this issue Sep 16, 2018 · 2 comments
Open

CSS-in-rs #27

qm3ster opened this issue Sep 16, 2018 · 2 comments

Comments

@qm3ster
Copy link
Contributor

qm3ster commented Sep 16, 2018

I don't understand the purpose of the current behavior of the css! macro.
Why is CSS being written to an external file, regardless of if the component will ever be displayed or not?
I feel like having the component own its css makes more sense than a macro writing files during compilation. This way, critical CSS can trivially be inlined during SSR.

@chinedufn
Copy link
Owner

Some prior discussion in #1

I think you'd still want to have the option to write to a file. One advantage on the write-to-file side of things is better caching since you don't have to re-download both the app and CSS when you only change the CSS (and vice versa). Often times application code will change way more often than styling.


But yeah - totally agree that the ability to inline would be useful. Any thoughts on how we might support both cleanly?

@qm3ster
Copy link
Contributor Author

qm3ster commented Sep 16, 2018

I think the two are at odds with each other. CSS-per-component is not something you want to extract and concat with all other CSS, because this means that a change to a single component's CSS anywhere in the app invalidates the whole CSS bundle. So, there's no immediate victory right now.
On the other hand, if you use a CSS framework, and style your components with classes from there, foregoing the css! macro, the framework can stay cached. I think the best solution for the time being would be to use a combination of the two approaches.
Otherwise, maybe multiple CSS files?
Yeah, wasm code splitting is nowhere close to solved yet, but if it is, it makes sense that components would be the unit of caching.

@ghost ghost mentioned this issue Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants