0

I've a file name base.less and another file private.less which imports base.less. In base.less I have this code

@media (min-width: @screen-sm-min) {

}

when I try to compile with lessc base.less private.css I get this error

NameError: variable @screen-sm-min is undefined in base.less

It's not my code and I'm new on less,somebody knows what is the problem?

Joe Taras
  • 15,166
  • 7
  • 42
  • 55
afsdi3
  • 117
  • 3
  • 11
  • Possible duplicate of [How can I use Bootstrap styles in a LESS file?](https://stackoverflow.com/questions/20767152/how-can-i-use-bootstrap-styles-in-a-less-file) – Seblor Sep 14 '18 at 07:31

1 Answers1

2

You need to add the variable @screen-sm-min to your base.less like this @screen-sm-min: 375px; before you use that variable somewhere. Ideally you create a file called vars.less and put all your variables in there and include that in your base.less file.

vars.less

@screen-sm-min: 375px;
@default-background-color: #fff;
@my-special-border-color: red;

Now you can use @screen-sm-min anywhere in your css. Also, check out http://lesscss.org/#variables

Sapulidi
  • 76
  • 4
  • 1
    Just a minor remark - in Less [you don't have](http://lesscss.org/features/#variables-feature-lazy-evaluation) to declare a variable *before* it's used. – seven-phases-max Sep 14 '18 at 10:15