Magento – magento 2 static content deploy error: @minicart-icon-color is undefined

deploymagento2

I have created a new theme, and deployed the static content, but it's giving me an error when the front-end static content deployment is running.

That is:

@minicart-icon-color is undefined in the view-processed file.

Please help me to solve this. Thanks.

Best Answer

@Hemant I don't see the @minicart-icon-color variable in my 2.1.2 codebase, so I'm assuming that's a variable that you created? If so, first you'd want to make sure it's, in fact, declared and assigned a value Less docs on variables.

Next, I'd suggest that you look at your custom theme's less files to see where you're trying to use that variable. It's very likely that you don't have access to @minicart-icon-color within the scope of where you're using it you can get away with using a reference import option to include your variable's definition within the scope of the less file(s) in question.

For example if I create a custom theme app/design/<Vendor>/<theme> and I create two less files...

  • app/design/<Vendor>/<theme>/web/css/source/a.less
  • app/design/<Vendor>/<theme>/web/css/source/b.less

and I define a variable in a.less, such as @minicart-icon-color, if I wanted to use that value in b.less I would need to import (@import) the less file where @minicart-icon-color is defined, in this case a.less.

So in b.less I would have @import "a"; @import reference in Dev Docs. I could also use @import (reference) "a"; if I don't want to copy over the variable definition again in b.less from a.less (again, you can refer to the less docs link on that from above).

You'll probably want to look for a similar situation in your code (I can't provide more suggestions without details). If that's covered and you're still getting the same issue...then it's probably due to the order in which your less files are being loaded. You control the order by using an _extend.less file (look through that link for examples on how to do so).

I hope this helps.