Using @variable for @import another LESS file

I would like to use my @variable (@variable: "file.less") to import file.less into main.less.

I tried this way:

@var: 'file.less'; @import @var 

or as follows:

 @import "@var" 

or

 @import "@{var}" 

but that will not work.

Any ideas?

+6
source share
3 answers

@imports are processed before @variables, so it will not work.

+1
source

Check out the beta for LESS 1.4.0. It should be able to handle variables in @import statements.

https://github.com/cloudhead/less.js/issues/410

 // An example from the issue for this feature: @theme: winter; @import "@{theme}/theme.less"; 

Beta is available for node through:

 npm install -g less@beta 

Or for the browser at https://github.com/cloudhead/less.js/blob/master/dist/less-1.4.0-beta.js

0
source

What about:

 @import url(@var); 

?


No, this does not work.

-1
source

Source: https://habr.com/ru/post/927913/


All Articles