Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use variables in LESS import statements

Tags:

css

less

If I am going to import multiple files from the same directory, I'd like to reuse the directory path (assuming the file with the import statements isn't in the same directory as the import targets). So far I've tried this:

@directoryPath: "../modules/core/less/";

@import @directoryPath + "file.less";
@import (@directoryPath + "file.less");
@import @{directoryPath}"file.less";
@import "@{directoryPath}file.less";

@filePath: @directoryPath + "file.less"; //I have verified this produces the proper string

@import @filePath;
@import @{filePath};

None of the 6 import statements work. Some of them work in the

source: url(/*LESS variables*/);

declaration, but don't work the same way in the @import statement. Any ideas on what will work?

like image 311
Tahsis Claus Avatar asked Mar 27 '15 01:03

Tahsis Claus


1 Answers

See Variables > Variable Interpolation > Import statements in the documentation.

The proper syntax is:

@path: "../modules/core/less/";

@import "@{path}file.less";
like image 129
seven-phases-max Avatar answered Oct 08 '22 05:10

seven-phases-max