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 values don't cause cascading updates #95

Open
tj opened this issue Apr 13, 2016 · 12 comments · May be fixed by #108
Open

CSS values don't cause cascading updates #95

tj opened this issue Apr 13, 2016 · 12 comments · May be fixed by #108

Comments

@tj
Copy link

tj commented Apr 13, 2016

Not sure where to report, but I'm seeing that only files that you edit are receiving value (https://github.com/css-modules/postcss-modules-values) changes. Is this the intended behaviour or possibly a bug? Took me a few minutes to realize what was going on, results popping in minutes later. Also if you have a file like colors.css, edit a value, nothing sees the change, until you edit those files.

I don't know the underlying mechanism for browserify etc so I can't comment on what would be going on, but it seems broken.

cheers

@tivac
Copy link

tivac commented Apr 13, 2016

Are you using watchify? It looks like css-modulesify doesn't listen for the update event from watchify and remove the updated files from its cache.

I ran into that with modular-css as well, tivac/modular-css#30 and fixed it by adding an update listener to my browserify plugin that removes the changed files from its cache so it can use the updated file contents.

https://github.com/tivac/modular-css/blob/master/src/browserify.js#L123-L127

@tj
Copy link
Author

tj commented Apr 13, 2016

Ahh interesting, yep I am using browserify/watchify via the CLI

@joshwnj
Copy link
Member

joshwnj commented Apr 14, 2016

Thanks for reporting it, definitely a bug.

And thanks for the notes @tivac

I haven't looked at fixing this in css-modulesify yet, as there are a couple of other improvements to make. Instead, I've been trying out an alternate approach which is now pretty close to feature parity with css-modulesify but fixes things like the bug described here.

There are still some changes I want to make, and then we'll consider whether it will replace css-modulesify (as a major version) or stay its own thing: https://github.com/joshwnj/cmify

Also works great with hot reloading (via browserify-hmr): https://github.com/joshwnj/css-modules-starter-kit/tree/postcss

@tj
Copy link
Author

tj commented Apr 18, 2016

hmm seems like it never detects a change to produce the --output file actually. Refresh works fine but otherwise no file is created, preventing things like browsersync from working.

@joshwnj
Copy link
Member

joshwnj commented Apr 19, 2016

Interesting, I haven't used browsersync. @tj are you using browsersync in a way that wouldn't also be be suitably solved by browserify-hmr?

@tj
Copy link
Author

tj commented Apr 19, 2016

Is browserify-hmr supposed to support CSS? I was using it for a while but ended up removing it since only it only supports stateful components and I didn't want to sprinkle the 'ud' module all over. I just thought that when you edit the css that it would save out to whatever your --output happens to be. I'm not really sure what state of the art is to be honest haha, too many options

@gersomvg
Copy link

gersomvg commented May 2, 2016

I've got the same issue here. I need to do an additional save on one of the involved CSS files before the result of a changed value in colors.css actually streams to the browser with BrowserSync. Let me know if there are any workarounds! 😄

@joshwnj
Copy link
Member

joshwnj commented Jun 17, 2016

Quick status update, I've got a solution for this working locally that I hope to put into a PR, once I've checked it a bit more thoroughly. So far @values are being propagated correctly in things like browser-sync and budo.

@spenserw
Copy link

@joshwnj What is the status on that PR?

@joshwnj
Copy link
Member

joshwnj commented Sep 19, 2016

@spenserw ow, it's been a while hasn't it :P Life got suddenly busy. I'll put some more heat on this one.

joshwnj added a commit that referenced this issue Oct 5, 2016
rebuilds dependent css modules so that changes to values propagate (fixes #95)
@joshwnj joshwnj linked a pull request Oct 5, 2016 that will close this issue
@joshwnj
Copy link
Member

joshwnj commented Oct 5, 2016

@spenserw back from holidays now :) when you have a moment could you please try #108 and let me know if it's working for you?

@spenserw
Copy link

spenserw commented Oct 5, 2016

@joshwnj Will try as soon as I get a chance, thanks for the quick turnaround time!

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

Successfully merging a pull request may close this issue.

5 participants