Importing a nonexistent file into LESS

I have a file styles.less

that is importing a file variables.less

.

For usage purposes, I would like to have a file theme.less

that overrides variables variables.less

.

Mine styles.less

will look like

@import 'variables';
@import 'theme';

.my-class {
   background: @bg;
}

      

The problem occurs when the file theme.less

doesn't exist (i.e. if I don't want to apply any theme) as LESS has a compilation process after the error is thrown.

Is there a way to make it less likely to throw a warning if the file doesn't exist and continue compiling?

+3


source to share


1 answer


Try the following:

@import (optional) "foo.less";



font: http://lesscss.org/features/#import-directives-feature

+6


source







All Articles