akanix42 / meteor-css-modules

MIT License
92 stars 20 forks source link

Bundle css on server and return to client #128

Open TimoRuetten opened 5 years ago

TimoRuetten commented 5 years ago

We are using Serverside rendering so we would like to send the generated css classes from the server to the client. Is there any way to solve this with your package?

If we do not send the css directly to the client from server the first render - which the user sees - does not have the styles. A second later the styles get appended to the elements which is a bit ugly on the first render.

akanix42 commented 5 years ago

Currently this is not a feature of my package, but it may be possible to add it. How are you performing SSR and how do you envision sending the CSS? For example, we could add an additional export that allows you to access the CSS directly from your code: import styles, { css } from './foo.css';

TimoRuetten commented 5 years ago

There could be 2 ways in my opinion.

1 All css files which are imported could be bundled when the Meteor Server restarts and put all together in one file which can be added to the

2 Like in your example it could be possible to extract the css of the file and add it to a self written CSS which has the context of all CSS code on Serverside and can append a