grass icon indicating copy to clipboard operation
grass copied to clipboard

Can make 'grass::from_string_with_file_name' as pub?

Open dhlolo opened this issue 4 years ago • 3 comments

As title, I need use grass in my custom project, there are some complicated path calculation need to do, such as custom alias rules. But found that 'grass::from_string_with_file_name' can not be used.

dhlolo avatar Apr 07 '22 15:04 dhlolo

Hello,

I am happy to do this, though I am interested a bit more in your specific use case. That file name should only be used in error messages when the error occurs in the main file. Is there any reason you wish to change this? Perhaps you are looking for grass::Options::fs, which will allow you write code to intercept imports.

connorskees avatar Apr 10 '22 02:04 connorskees

I saw that grass::Options::fs needs a 'Fs' as param. I just want to implement a alias importer for '@scss/...', is there a simple example?

dhlolo avatar Apr 26 '22 11:04 dhlolo

Actually I am working on custom importers like libsass in rust.

dhlolo avatar May 04 '22 16:05 dhlolo

Closing this issue as grass::Options::fs should allow one to solve the problem as described. You can find a simplified example of this in our tests:

https://github.com/connorskees/grass/blob/39c992a2eb9f2ef75175726b6e206b158349319e/tests/macros.rs#L117-L122

A simple importer implementation should be able to just strip the @scss/ prefix before passing the path to the file system.

connorskees avatar Dec 29 '22 07:12 connorskees