Closed KingMob closed 5 years ago
Oh this is interesting, but not trivial as you have to trace dependencies, correct?
But bringing more sophistication to the process would be interesting.
After poring over goog.cssom
, I don't think it should be too bad to implement, since it traces the deps for you. When calling goog.cssom.getAllCssStyleSheets()
, it recurses on @import
rules, and produces a completely ordered list. (Since @imports
can only be at the start of a CSS file, there's never any worries about splicing into the middle of a sheet's rules.) If we need to go back up a deps tree, there's the .parentStyleSheet
property.
I see several possibilities. Let me know what you think.
.parentStyleSheet
repeatedly to find its top-level parent CSS file, and then reload at the top-level.
@imports
the rest.CSSImportRule
, remove it, and re-add it to the parent, forcing it to reload just that child.
I personally think option 2 is a good trade-off, followed by option 1. Option 3 is probably overkill, but if the CSS was huge or the DOM mega-slow, it might be worth considering.
@bhauman, have you had a chance to think about it?
I'm leaning towards option 1 because of its simplicity. Reloading extra CSS is never really a problem.
OK, I'll work on option 1 and get back to you when I get a chance.
If we have a
parent.css
in the HTML that does@import "child.css";
, updates tochild.css
will not be reloaded by Figwheel.The current behavior is
reload-css-file
callsget-correct-link
which callscurrent-links
, which only looks at<link>
tags already in the document.FWIW, I know
goog.cssom.getAllCssStyleSheets()
includes imports correctly.I can tackle this if you want to include it, but it might take a few weeks with the holidays before I have some time.