Open martinothamar opened 3 years ago
Hi Martin!
The resolving of @import
directives are handled as part of the compilation process in LibSassHost - so might be best to check there...
In general if you can resolve the path & test with File.Exists("./filepath.scss")
it should work. Looking at your examples I don't think they'll resolve because:
@import 'wwwroot/variables.scss';
- checks in same directory (not found)@import '/wwwroot/variables.scss';
- checks from root (not found)@import '~/wwwroot/variables.scss';
- virtual directory (don't think this is resolving correctly, I'm not sure how to either 🤷 )Delegate.SassBuilder
actually wrapped another packaged tool sassc.exe
for its compilation, and I really have no idea what magic happened there.
I've just been using relative paths @import '../../wwwroot/_variables.scss'
which works fine. Hope this helps.
It seems like it is linked to the current working directory for sassc.exe. We might be able to temporarily change the directory in lsb.exe and restore it afterwards? Pass the working directory as an option to lsb.exe?
Forgot to answer this :) Reason I prefer imports relative to root is it makes refactoring easier if files are moved around.
@import '/wwwroot/variables.scss';
- checks from root (not found)
I guess this is the scenario I would expect to work, in that this library compiles in context of the project, and the wwwroot folder is at the root of the project. I'm not familiar with LibSassHost (and limited experience with sass in general), but do you think the IncludePaths
argument would help me here?
Actually I was waiting/hoping for any progress on sass-dart progress, before starting work on this: https://github.com/Taritsyn/LibSassHost/issues/42#issuecomment-721210036
https://github.com/Taritsyn/SassHost/issues/1
Seems that project has been postponed, currently I have limited time, otherwise I might check the current state of that commit.
See pull request #30 If that is integrated, we could pick this issue up again.
Hey, just started using this in a Blazor webassembly app. Working great, but when I want to import a another file for variables it doesn't work out too well. I have color variables in a top level folder which will be needed many places, and I would like to import relative to project root. This worked with the Delegate.SassBuilder project (
@import 'wwwroot/variables.scss';
), but since this library seems actively maintained and well designed I have switched to this library. Is there a way to do imports relative to project root currently? I.e.@import 'wwwroot/variables.scss';
@import '/wwwroot/variables.scss';
@import '~/wwwroot/variables.scss';