Open sergeche opened 9 years ago
By dependencies do you mean @import
s?
No, @import
are already scanned.
I mean this use case:
// global.css
@import bourbon;
@import "./layout";
// layout.css
div {
@include size(100px, 200px);
}
In layout.css
, @include size()
assumes that this mixin lib(Bourbon) is added somewhere in parent stylesheet but since layout.css
doesn’t have explicit @import bourbon;
LiveStyle can’t find size()
mixin and simply ignores it.
I want to create a scanner that automatically find all stylesheets used (like Bourbon) and use their mixins.
I want to create a scanner that automatically find all stylesheets used
Apologies if I'm missing something, but doesn't this mean parsing and following all @import
s?
Scanning all stylesheets in project/folder. LS already follows @import
s in edited stylesheet
Wouldn't that cause false positives though? Presumable LS should ignore mixins/functions that part of the current files import chain since less/Sass wouldn't be aware of the mixins (and likely error).
This is doubly for functions which, in the case of Sass, just get output as is with the expectation that it's a native css function.
Yes, it can potentially introduce errors and wrong mixin matches. I want create a possible solution for issue described above so I just wrote a note to myself :)
Sorry for hijacking :) I write lots of Sass tooling and am following this project closely. This issue got me curious about a possible https://github.com/xzyfer/sass-graph tie in.
Yeah, something like that. The main problem is how to determine a starting point for scanning, assuming you may just open a single stylesheet file in editor (e.g. you don’t know the project root).
Or maybe just make a solution for quickly adding a custom file as global dependency for all stylesheets in current project. Say, a right-click on it in sidebar and picking “Add to LiveStyle global dependencies”.
I expect you could (relatively?) safely walk up the directory tree until you don't see any more preprocessor files for N directories.
I have to parse those stylesheets into LS object model and keep them in memory. So parsing all stylesheets found under parent directories could lead to massive memory and CPU usage
I agree. Doing so using @import
s as a sort of whitelist could help. In the case of Sass, there isn't any kind of import path magic (yet), so you can (relatively?) safely match file path suffixes.
Providing explicit preprocessor dependencies might be a bit cumbersome for lazy people (like me). Think about a way how to automatically scan possible sources of mixins and variables for currently opened project/folder in Sublime Text