-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use sass-graph for accurate sass watching #629
Use sass-graph for accurate sass watching #629
Conversation
bf0d744
to
030f8cc
Compare
This is super awesome. 👍 Considering this request: #590, I didn't knew something like sass-graph existed! 😄 I think node-sass should not expose this functionality (or expose the show-graph feature) to its API. That would be against the laws of DRY (especially now where have package referenced here). |
It didn't really til today... |
030f8cc
to
91d26b8
Compare
@xzyfer any idea how it will play with custom importers in 2.0? |
I've isolated this functionality explicitly to the watch function in the cli. The graph doesn't even exist until you being watch so there shouldn't be any leakage. |
oOo.. Did you release it today for the first time? I saw old PRs in your repo, thought it out there for a while.. :) |
@browniefed sass-graph currently follows the native sass model. It'll walk imports, if the file exists on disk in an include path it's be added to an in memory graph. That graph is then used to find the collection or top-most ancestors which should be re-compiled. ATM it has no knowledge of custom importers. |
@xzyfer I guess I was implying it'd be cool if it could accept an importer, likely the same one that would be used for node-sass, so both things could pair up in terms of custom importer logic. |
Can we take the Or if it is not possible to retain the JS object, then perhaps function-to-string approach: |
@am11 It's been in various stages of development for a while, but I released 1.0.0 a couple hours ago in preparation for getting it into node-sass for my dev team :) |
Custom importers may very well be possible in future versions. |
On second thought, we may only want to store the path to custom importer in graph and then re-require it in watch even handler. (whichever approach is elegant). Yes the importers can certainly wait, since you might like to consider providing room for the future "custom functions" as well (which will behave the same way, except there will by a multiplicity factor -- spoiler alert!!). :) |
b7f9e0a
to
81f76fc
Compare
aha! CI is passing :D 🎉 |
@@ -139,6 +139,8 @@ describe('cli', function() { | |||
|
|||
bin.stderr.setEncoding('utf8'); | |||
bin.stderr.on('data', function(data) { | |||
console.log('=> changed: ' + src); | |||
console.log(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be rebased out. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in a35326a
81f76fc
to
a35326a
Compare
🎉 Feel free to merge it whenever you think this is ready. Maybe we can set sass-graph to |
a35326a
to
fa13e98
Compare
I generally give npm the benefit of the doubt but better safe than sorry. I've update this. When all the builds pass I'll give it a run on my local Libsass 3.2.0 fork then ship it. |
Works amazingly! Are those AppVeyor failures expected? |
Yup! :) |
…argets Use sass-graph for accurate sass watching
🎉 🚀 |
Yay! :) |
Problem
The watcher is broken. So very broken. Two major problems with it
_
) which is a big no-noAssuming the following directory structure
where
foo.scss
andbar.scss
, and running the following commandnode-sass -w -r --output dist src
.A modification to
src/components/_baz.scss
should not compile_baz.scss
. It should traverse the import graph and compiledist/foo.css
anddist/bar.css
.This is how the native sass watcher works.
Solution
Use sass-graph to build an in memory graph of the
@imports
to determine the correct compilation targets for a modified file.I believe this is the issue at the heart of #157.