-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Reuse styles between server and client #1132
Conversation
1312622
to
2a4b934
Compare
@frenzzy Is there a reason why you cannot/don't want publish this as a library or update to |
I really want to make this stuff available as external module but the desired solution touches different parts of application and build process. Here is my vision of composite parts:
Suggestions about how to move it into module(s) are welcome. |
It is still in my mind but I'm loosing idea about how this works. |
2a4b934
to
11b1c12
Compare
Hey @frenzzy, I've managed to implement this in a modified fork of RSK, but the hot styles are now always 1 version behind. As an example, if I start out with: body {
background: white;
} ...and run body {
background: orange;
} ...and save the file. I then change the CSS to: body {
background: black;
} ...and the CSS hot-updates and the I dug around the code trying to find the culprit, and I have a feeling it's in your custom loader, or the withStyles HOC I'd really appreciate a pointer. Thanks! |
@WillemLabu hey, in this PR after hot update received, happens following:
|
Not too familiar with how the HMR bubbles through the app, but it seems the I've just removed the // Enable Hot Module Replacement (HMR)
if (module.hot) {
WithStyles.prototype.componentWillReceiveProps = function componentWillReceiveProps() {
this.inserted = styles.map(s => insertCss(s.getCss(), true));
};
} It's probably not the best way of going about things, but it works. |
Hi @frenzzy, not sure if directly related, but You can use MiniCssExtractPlugin in production, style-loader in development for client, You don't need What do you think? I'm just working on this for my customer and it looks working really nicely ❤️ |
Yes, maybe.. need to try it out. |
@frenzzy thank you very much for this PR! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion. NOTE: The |
isomorphic-style-loader
replaced with custominline-css-loader
which is modified version of original css-loaderwithStyles
componentP.S.: This is an experimental PR and these changes probably won't be merged into the master branch as they are. To be discussed...
P.P.S: Your help with testing is very appreciated. Thanks!