LESS - import another file from url

I've seen that I can import even fewer files from the URL, with the @import command (for example: @import (reference) "https://s3-us2.amazonaws.com/s.cdpn.io/18728/pure.less"

)

But - I want it to be customizable . I am working with Visual Studio and I have a parent solution that contains my fewer files.I want to use this file in my child solutions, but I cannot do it with a relative path (compilation will fail because the file does not exist in the child solution), so it seems to me that this is the only way to do this import via URL.

My problem with importing by url is changing the url to fit the environment (dev / qa / prod etc.). I want it to set up environments somewhere so the LESS file "knows" to get the correct value.

In the end, I want it to be something like: @import (reference) "https://web.<environment>.com/pure.less"

Of course there must be some kind of variable.

Hope you can understand my problem.

Thank.

+3


source to share


1 answer


If your config variable is a LESS variable that can be accessed when invoking the import statement, you can simply use variable interpolation in the import statement :



@import "settings"; // this is where @environment: "dev"; is set
@import (reference) "https://web.@{environment}.com/pure.less";

      

+2


source







All Articles